简体   繁体   English

由于 gyp 错误,我无法运行任何项目。 我该如何解决这个问题:npm ERR! gyp 动词 cli

[英]I cannot run any project because of gyp error. How can I fix this: npm ERR! gyp verb cli

Whenever I run my code I always get the same error.每当我运行我的代码时,我总是会遇到同样的错误。 I uninstall node and npm and reinstall.我卸载节点和 npm 并重新安装。 But now there is no "node_modules" and I get the same error.但是现在没有“node_modules”,我得到了同样的错误。 How can I fix it?我该如何解决?

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

There isn't node-sass and node-gyp.没有 node-sass 和 node-gyp。 When I tried to install them I also got the same error.当我尝试安装它们时,我也遇到了同样的错误。 I cannot install anything.我无法安装任何东西。

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

Please don't waste your time running the suggested command by others.请不要浪费时间运行其他人建议的命令。 Please uninstall node.js and use the Node v14.x.请卸载 node.js 并使用 Node v14.x。 It will solve it automatically.它会自动解决它。

I got the same error and did this:我得到了同样的错误并这样做了:

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

With most of the operating systems removing python2 this is a common issue for most projects.由于大多数操作系统都删除了 python2,这对于大多数项目来说是一个常见问题。 It definitely affected 4/5 of my recent projects after upgrading to current Linux/Debian Stable which removed python2.在升级到删除了 python2 的当前 Linux/Debian Stable 后,它肯定影响了我最近项目的 4/5。

The solution is for system to start using python3 and in order to do that you need to..解决方案是系统开始使用 python3 并且为了做到这一点你需要..

Solution/Solved is:解决方案/已解决是:

node-sass is actually at fault. node-sass 实际上是错误的。 Python2 is required until version 6.0.0. 6.0.0 版之前需要 Python2。 Normally you would upgrade to latest 7.0.3 but node-sass is currently obsolete, so we will swap to sass project.通常您会升级到最新的 7.0.3,但 node-sass 目前已过时,因此我们将切换到 sass 项目。

yarn remove node-sass
yarn add sass

I've given more details on reasoning why here, or alternative dart-sass if you use "render() and renderSync() functions".:如果您使用“render() 和 renderSync() 函数”,我已经给出了更多关于原因的详细信息,或者替代的 dart-sass:

Solved-ERR.gyp-info-using-node-gyp-3.8.0-gyp-verb-which-failed-Error-not-found-python2 已解决-ERR.gyp-info-using-node-gyp-3.8.0-gyp-verb-which-failed-Error-not-found-python2

Affected:做作的:

  • node.js /react web apps node.js /反应 web 应用
  • Elixir/Phoenix assets Elixir/Phoenix 资产
  • Android apps Android 应用
  • Vue.js projects Vue.js 项目

Do not use node-sass anymore.不再使用 node-sass。 Remove 'node-sass' in package.json.删除 package.json 中的“node-sass”。 pls use 'dart-sass'.请使用'dart-sass'。

https://www.npmjs.com/package/dart-sass (dart-sass is default now) https://www.npmjs.com/package/dart-sass (dart-sass 现在是默认的)

!important !重要的

i run into the same issue.我遇到了同样的问题。 ANd What I recomend to you is to install nvm to control your node version instead of unistalling the current version causing other problems with the existent projects.我向您推荐的是安装nvm来控制您的节点版本,而不是卸载当前版本导致现有项目出现其他问题。

NVM Installation Guide NVM 安装指南

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

or或者

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

After installation安装后

After you are sure that you'd installed nvm successfully you can do:在确定已成功安装nvm之后,您可以执行以下操作:

  1. nvm --version to check if nvm is successfully installed nvm --version检查nvm是否安装成功
  2. nvm install [desired node version] ex.: nvm install 14.0.0 nvm install [desired node version]例如: nvm install 14.0.0
  3. nvm list to check all node versions installed nvm list检查所有安装的节点版本
  4. nvm use [desired version] to change between node version ex.: nvm use 14.0.0 nvm use [desired version]在节点版本之间切换例如: nvm use 14.0.0

Conclusion结论

As I mention above, instead of unistalling your node versions you can install different versions of node and changing between then avoid future errors.正如我上面提到的,您可以安装不同版本的节点并在它们之间进行更改,而不是卸载您的节点版本,从而避免将来出现错误。

Be Happy even with bugs即使有虫子也要快乐

The following solution works for me.以下解决方案对我有用。

Try:尝试:

npm cache clean --force

npm uninstall node-sass

Uninstall node modules from your project从项目中卸载节点模块

npm i sass --save

Removing node-sass worked for me also删除 node-sass 也对我有用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM