npm install failed at node-sass命令失败

vzgqcmou  于 2023-10-19  发布在  其他
关注(0)|答案(4)|浏览(162)

如题。我维护了一个项目,该项目的网页是使用Angular.js和一些实用程序开发的,但当我使用“npm install”命令时出错了,错误日志如下所示。.

  1. 2094 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Gary.Lu\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install"
  2. 2095 verbose node v16.13.1
  3. 2096 verbose npm v8.3.0
  4. 2097 error code 1
  5. 2098 error path C:\Users\Gary.Lu\Documents\ITTS Projects\AXMES\MAIN\ITTS-MES\WEB\node_modules\node-sass
  6. 2099 error command failed
  7. 2100 error command C:\WINDOWS\system32\cmd.exe /d /s /c node scripts/build.js
  8. 2101 error Building: C:\Program Files\nodejs\node.exe C:\Users\Gary.Lu\Documents\MyWeb\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
  9. 2102 error gyp info it worked if it ends with ok
  10. 2102 error gyp verb cli [
  11. 2102 error gyp verb cli 'C:\\Program Files\\nodejs\\node.exe',
  12. 2102 error gyp verb cli 'C:\\Users\\Gary.Lu\\Documents\\MyWeb\\node_modules\\node-gyp\\bin\\node-gyp.js',
  13. 2102 error gyp verb cli 'rebuild',
  14. 2102 error gyp verb cli '--verbose',
  15. 2102 error gyp verb cli '--libsass_ext=',
  16. 2102 error gyp verb cli '--libsass_cflags=',
  17. 2102 error gyp verb cli '--libsass_ldflags=',
  18. 2102 error gyp verb cli '--libsass_library='
  19. 2102 error gyp verb cli ]
  20. 2102 error gyp info using [email protected]
  21. 2102 error gyp info using [email protected] | win32 | x64
  22. 2102 error gyp verb command rebuild []
  23. 2102 error gyp verb command clean []
  24. 2102 error gyp verb clean removing "build" directory
  25. 2102 error gyp verb command configure []
  26. 2102 error gyp verb check python checking for Python executable "python2" in the PATH
  27. 2102 error gyp verb `which` failed Error: not found: python2
  28. 2102 error gyp verb `which` failed at getNotFoundError (C:\Users\Gary.Lu\Documents\MyWeb\node_modules\which\which.js:13:12)
  29. 2102 error gyp verb `which` failed at F (C:\Users\Gary.Lu\Documents\MyWeb\node_modules\which\which.js:68:19)
  30. 2102 error gyp verb `which` failed at E (C:\Users\Gary.Lu\Documents\MyWeb\node_modules\which\which.js:80:29)
  31. 2102 error gyp verb `which` failed at C:\Users\Gary.Lu\Documents\MyWeb\node_modules\which\which.js:89:16
  32. 2102 error gyp verb `which` failed at C:\Users\Gary.Lu\Documents\MyWeb\node_modules\isexe\index.js:42:5
  33. 2102 error gyp verb `which` failed at C:\Users\Gary.Lu\Documents\MyWeb\node_modules\isexe\windows.js:36:5
  34. 2102 error gyp verb `which` failed at FSReqCallback.oncomplete (node:fs:198:21)
  35. 2102 error gyp verb `which` failed python2 Error: not found: python2
  36. 2102 error gyp verb `which` failed at getNotFoundError (C:\Users\Gary.Lu\Documents\MyWeb\node_modules\which\which.js:13:12)
  37. 2102 error gyp verb `which` failed at F (C:\Users\Gary.Lu\Documents\MyWeb\node_modules\which\which.js:68:19)
  38. 2102 error gyp verb `which` failed at E (C:\Users\Gary.Lu\Documents\MyWeb\node_modules\which\which.js:80:29)
  39. 2102 error gyp verb `which` failed at C:\Users\Gary.Lu\Documents\MyWeb\node_modules\which\which.js:89:16
  40. 2102 error gyp verb `which` failed at C:\Users\Gary.Lu\Documents\MyWeb\node_modules\isexe\index.js:42:5
  41. 2102 error gyp verb `which` failed at C:\Users\Gary.Lu\Documents\MyWeb\node_modules\isexe\windows.js:36:5
  42. 2102 error gyp verb `which` failed at FSReqCallback.oncomplete (node:fs:198:21) {
  43. 2102 error gyp verb `which` failed code: 'ENOENT'
  44. 2102 error gyp verb `which` failed }
  45. 2102 error gyp verb check python checking for Python executable "python" in the PATH
  46. 2102 error gyp verb `which` succeeded python C:\Python310\python.EXE
  47. 2102 error gyp ERR! configure error
  48. 2102 error gyp ERR! stack Error: Command failed: C:\Python310\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
  49. 2102 error gyp ERR! stack File "<string>", line 1
  50. 2102 error gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
  51. 2102 error gyp ERR! stack ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  52. 2102 error gyp ERR! stack SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
  53. 2102 error gyp ERR! stack
  54. 2102 error gyp ERR! stack at ChildProcess.exithandler (node:child_process:397:12)
  55. 2102 error gyp ERR! stack at ChildProcess.emit (node:events:390:28)
  56. 2102 error gyp ERR! stack at maybeClose (node:internal/child_process:1064:16)
  57. 2102 error gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
  58. 2102 error gyp ERR! System Windows_NT 10.0.19044
  59. 2102 error gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Gary.Lu\\Documents\\MyWeb\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
  60. 2102 error gyp ERR! cwd C:\Users\Gary.Lu\Documents\MyWeb\node_modules\node-sass
  61. 2102 error gyp ERR! node -v v16.13.1
  62. 2102 error gyp ERR! node-gyp -v v3.8.0
  63. 2102 error gyp ERR! not ok
  64. 2102 error Build failed with error code: 1
  65. 2103 verbose exit 1
  66. 2104 timing npm Completed in 53164ms
  67. 2105 verbose unfinished npm timer reify 1640746055969
  68. 2106 verbose unfinished npm timer reify:build 1640746094013
  69. 2107 verbose unfinished npm timer build 1640746094014
  70. 2108 verbose unfinished npm timer build:deps 1640746094014
  71. 2109 verbose unfinished npm timer build:run:postinstall 1640746099176
  72. 2110 verbose unfinished npm timer build:run:postinstall:node_modules/node-sass 1640746099176
  73. 2111 verbose code 1
  74. 2112 error A complete log of this run can be found in:
  75. 2112 error C:\Users\Gary.Lu\AppData\Local\npm-cache\_logs\2021-12-29T02_47_34_408Z-debug-0.log

但是当我使用Angular 12构建另一个项目时,我没有遇到同样的错误。重要吗?还是我错过了一些没有它就无法建立的东西?有人能指导我解决吗?

yshpjwxd

yshpjwxd1#

我也有这个问题,我做了什么:
1-npm uninstall node-sass
2-npm i -D sass
3-npm I

lbsnaicq

lbsnaicq2#

这通常是因为自运行npm install以来,您的环境发生了变化。运行npm rebuild node-sass下载当前环境的绑定。”
所以我运行了npm rebuild node-sass,它工作了!然后安装npm,一切正常。

vxf3dgd4

vxf3dgd43#

node-sass需要限制节点版本,您需要检查节点的版本与哪个node-sass兼容。

oug3syen

oug3syen4#

首先,弄清楚你的sass中使用的Python版本和Node版本。节点版本可以通过在包中搜索找到,它看起来像这样

  1. "engines": {
  2. "node": ">=8.0.0"
  3. }

对于绑定文件中的python版本

  1. 'python': ['<3.10.0>'],

然后安装Node和Python所需的版本
如果你已经安装了nvm,你可以使用

  1. nvm install @version_name

对于Python,您必须从Python网站下载所需的版本,然后将其值添加到系统变量中

相关问题