簡體   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

每當我運行我的代碼時,我總是會遇到同樣的錯誤。 我卸載節點和 npm 並重新安裝。 但是現在沒有“node_modules”,我得到了同樣的錯誤。 我該如何解決?

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。 當我嘗試安裝它們時,我也遇到了同樣的錯誤。 我無法安裝任何東西。

我通過將節點版本更改為 14.15.1 解決了這個問題

請不要浪費時間運行其他人建議的命令。 請卸載 node.js 並使用 Node v14.x。 它會自動解決它。

我得到了同樣的錯誤並這樣做了:

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

由於大多數操作系統都刪除了 python2,這對於大多數項目來說是一個常見問題。 在升級到刪除了 python2 的當前 Linux/Debian Stable 后,它肯定影響了我最近項目的 4/5。

解決方案是系統開始使用 python3 並且為了做到這一點你需要..

解決方案/已解決是:

node-sass 實際上是錯誤的。 6.0.0 版之前需要 Python2。 通常您會升級到最新的 7.0.3,但 node-sass 目前已過時,因此我們將切換到 sass 項目。

yarn remove node-sass
yarn add sass

如果您使用“render() 和 renderSync() 函數”,我已經給出了更多關於原因的詳細信息,或者替代的 dart-sass:

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

做作的:

  • node.js /反應 web 應用
  • Elixir/Phoenix 資產
  • Android 應用
  • Vue.js 項目

不再使用 node-sass。 刪除 package.json 中的“node-sass”。 請使用'dart-sass'。

https://www.npmjs.com/package/dart-sass (dart-sass 現在是默認的)

!重要的

我遇到了同樣的問題。 我向您推薦的是安裝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

結論

正如我上面提到的,您可以安裝不同版本的節點並在它們之間進行更改,而不是卸載您的節點版本,從而避免將來出現錯誤。

即使有蟲子也要快樂

以下解決方案對我有用。

嘗試:

npm cache clean --force

npm uninstall node-sass

從項目中卸載節點模塊

npm i sass --save

刪除 node-sass 也對我有用

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM