我不能运行任何项目,因为gyp错误,我如何解决这个问题:npm错误!gyp动词命令行

lrl1mhuk  于 2022-11-14  发布在  其他
关注(0)|答案(6)|浏览(305)

每当我运行我的代码我总是得到同样的错误。我卸载节点和npm并重新安装。但现在没有“节点模块”,我得到同样的错误。我该如何修复它?

npm ERR! code 1
npm ERR! path /Users/bng/Desktop/deneme/12-vue-spa/node_modules/node-sass
npm ERR! command failed
npm ERR! command sh -c node scripts/build.js
npm ERR! Building: /usr/local/bin/node /Users/bng/Desktop/deneme/12-vue-spa/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli   '/usr/local/bin/node',
npm ERR! gyp verb cli   '/Users/bng/Desktop/deneme/12-vue-spa/node_modules/node-gyp/bin/node-gyp.js',
npm ERR! gyp verb cli   'rebuild',
npm ERR! gyp verb cli   '--verbose',
npm ERR! gyp verb cli   '--libsass_ext=',
npm ERR! gyp verb cli   '--libsass_cflags=',
npm ERR! gyp verb cli   '--libsass_ldflags=',
npm ERR! gyp verb cli   '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@16.14.2 | darwin | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb check python checking for Python executable "python2" in the PATH
npm ERR! gyp verb `which` failed Error: not found: python2
npm ERR! gyp verb `which` failed     at getNotFoundError (/Users/bng/Desktop/deneme/12-vue-spa/node_modules/which/which.js:13:12)
npm ERR! gyp verb `which` failed     at F (/Users/bng/Desktop/deneme/12-vue-spa/node_modules/which/which.js:68:19)
npm ERR! gyp verb `which` failed     at E (/Users/bng/Desktop/deneme/12-vue-spa/node_modules/which/which.js:80:29)
npm ERR! gyp verb `which` failed     at /Users/bng/Desktop/deneme/12-vue-spa/node_modules/which/which.js:89:16
npm ERR! gyp verb `which` failed     at /Users/bng/Desktop/deneme/12-vue-spa/node_modules/isexe/index.js:42:5
npm ERR! gyp verb `which` failed     at /Users/bng/Desktop/deneme/12-vue-spa/node_modules/isexe/mode.js:8:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp verb `which` failed  python2 Error: not found: python2
npm ERR! gyp verb `which` failed     at getNotFoundError (/Users/bng/Desktop/deneme/12-vue-spa/node_modules/which/which.js:13:12)
npm ERR! gyp verb `which` failed     at F (/Users/bng/Desktop/deneme/12-vue-spa/node_modules/which/which.js:68:19)
npm ERR! gyp verb `which` failed     at E (/Users/bng/Desktop/deneme/12-vue-spa/node_modules/which/which.js:80:29)
npm ERR! gyp verb `which` failed     at /Users/bng/Desktop/deneme/12-vue-spa/node_modules/which/which.js:89:16
npm ERR! gyp verb `which` failed     at /Users/bng/Desktop/deneme/12-vue-spa/node_modules/isexe/index.js:42:5
npm ERR! gyp verb `which` failed     at /Users/bng/Desktop/deneme/12-vue-spa/node_modules/isexe/mode.js:8:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21) {
npm ERR! gyp verb `which` failed   code: 'ENOENT'
npm ERR! gyp verb `which` failed }
npm ERR! gyp verb check python checking for Python executable "python" in the PATH
npm ERR! gyp verb `which` succeeded python /Users/bng/opt/anaconda3/bin/python
npm ERR! gyp ERR! configure error 
npm ERR! gyp ERR! stack Error: Command failed: /Users/bng/opt/anaconda3/bin/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack   File "<string>", line 1
npm ERR! gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack                       ^
npm ERR! gyp ERR! stack SyntaxError: invalid syntax
npm ERR! gyp ERR! stack 
npm ERR! gyp ERR! stack     at ChildProcess.exithandler (node:child_process:399:12)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:526:28)
npm ERR! gyp ERR! stack     at maybeClose (node:internal/child_process:1092:16)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
npm ERR! gyp ERR! System Darwin 21.4.0
npm ERR! gyp ERR! command "/usr/local/bin/node" "/Users/bng/Desktop/deneme/12-vue-spa/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd /Users/bng/Desktop/deneme/12-vue-spa/node_modules/node-sass
npm ERR! gyp ERR! node -v v16.14.2
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok 
npm ERR! Build failed with error code: 1

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/bng/.npm/_logs/2022-03-24T08_05_44_961Z-debug-0.log

没有node-sass和node-gyp。当我试图安装它们时,我也得到了同样的错误。我不能安装任何东西。

am46iovg

am46iovg1#

!重要

我遇到了同样的问题。我向你推荐的是安装nvm来控制你的节点版本,而不是卸载当前版本,导致现有项目的其他问题。

NVM安装指南

https://www.geeksforgeeks.org/how-to-install-and-use-nvm-on-windows/

https://tecadmin.net/install-nvm-macos-with-homebrew/

安装后

在确定已成功安装nvm后,您可以执行以下操作:

  1. nvm --version,检查nvm是否已成功安装
  2. nvm install [desired node version]例如:nvm install 14.0.0
  3. nvm list,用于检查安装的所有节点版本
  4. nvm use [desired version]在节点版本之间更改,例如:nvm use 14.0.0
    结论
    正如我在上面提到,您可以安装不同版本的节点并在它们之间进行更改,而不是卸载节点版本,从而避免将来出现错误。

即使有bug也要快乐

blpfk2vs

blpfk2vs2#

我通过将节点版本更改为14.15.1解决了此问题

e3bfsja2

e3bfsja23#

请不要浪费时间运行别人建议的命令,请卸载node.js,使用Node v14.x,它会自动解决。

cxfofazt

cxfofazt4#

请不要再使用node-sass。请移除package.json中的'node-sass'。请使用'dart-sass'。
https://www.npmjs.com/package/dart-sass(现在默认为dart-sass)

70gysomp

70gysomp5#

我得到了同样的错误,并这样做:

1. npm install node-sass
 2. npm install  
 3. npm ci
 4. ng serve --open (to launch the project ).
7d7tgy0s

7d7tgy0s6#

随着大多数操作系统删除python 2,这是大多数项目的常见问题。在升级到删除python 2的当前Linux/Debian Stable后,它肯定影响了我最近4/5的项目。
解决方案是让系统开始使用python3,为了做到这一点,你需要..
解决方案/已解决:
node-sass实际上是错误的。Python 2在6.0.0版本之前是必需的。通常您会升级到最新的7.0.3,但是node-sass目前已经过时,所以我们将切换到sass项目。

yarn remove node-sass
yarn add sass

我已经在这里给出了更多关于原因的细节,或者如果你使用“render()和renderSync()函数”,也可以使用dart-sass。
已解决的错误!gyp-info-using-node-gyp-3.8.0-失败的gyp-verb-找不到错误-python 2
受影响:

  • node. js/react网络应用程序
  • Elixir/Phoenix资产
  • Android应用程序
  • Vue.js项目

相关问题