iT邦幫忙

0

[ npm ERR! code 1 ] 我裝不起來CLI了啦,沒用過python卻一直跟我說python出問題

  • 分享至 

  • xImage

上禮拜有更新angulr版本(不知道是不是這個原因),
結果開專案發現 npm run start 跑不起來了!!
後來嘗試重新安裝CLI,結果CLI卸載後也不能裝了!!!
而且我沒有用過python卻一直跟我說python有問題!/images/emoticon/emoticon03.gif

關鍵錯誤:
1.python路徑是不是怪怪的?
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3
2.
npm ERR! gyp ERR! stack Error: Command failed: /Library/Frameworks/Python.framework/Versions/3.7/bin/python3 -c import sys; print "%s.%s.%s" % sys.version_info[:3];

錯誤回報list:

npm ERR! code 1
npm ERR! path /usr/local/lib/node_modules/angular-cli/node_modules/node-sass
npm ERR! command failed
npm ERR! command sh -c -- node scripts/build.js
npm ERR! Building: /usr/local/bin/node /usr/local/lib/node_modules/angular-cli/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   '/usr/local/lib/node_modules/angular-cli/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@18.12.1 | 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 "/Library/Frameworks/Python.framework/Versions/3.7/bin/python3" in the PATH
npm ERR! gyp verb `which` succeeded /Library/Frameworks/Python.framework/Versions/3.7/bin/python3 /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
npm ERR! gyp ERR! configure error 
npm ERR! gyp ERR! stack Error: Command failed: /Library/Frameworks/Python.framework/Versions/3.7/bin/python3 -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:412:12)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack     at maybeClose (node:internal/child_process:1091:16)
npm ERR! gyp ERR! stack     at Socket.<anonymous> (node:internal/child_process:449:11)
npm ERR! gyp ERR! stack     at Socket.emit (node:events:513:28)
npm ERR! gyp ERR! stack     at Pipe.<anonymous> (node:net:313:12)
npm ERR! gyp ERR! System Darwin 22.1.0
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/angular-cli/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd /usr/local/lib/node_modules/angular-cli/node_modules/node-sass
npm ERR! gyp ERR! node -v v18.12.1
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/wuchanglin/.npm/_logs/2022-11-17T13_57_41_005Z-debug-0.log

我嘗試過並失敗的修復方法:
1.重新安裝MacOS
2.brew install node@14 / brew unlink node / brew link node@14
https://stackoverflow.com/questions/67399785/how-to-solve-npm-install-error-npm-err-code-1
3.刪除node_modules和package-lock.json
重新npm install,npm start
4.node,npm降版

有人知道怎麼解決這個問題嗎@@??
完全不能寫程式了 /images/emoticon/emoticon04.gif

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中
0
dante
iT邦新手 5 級 ‧ 2022-11-16 21:46:13

方法 1

把 npm 更新到最新版本看看

npm install -g npm@latest

方法 2

先確定 angular 版本和需要的 nodejs 版本

@angular/core/package.json 中的 engines

  1. 安裝 node mvn
  2. mvn 安裝 angular 需要的 nodejs 版本
  3. mvn 切換到指定版本
  4. 安裝 angular CLI
  5. 如果 npm ERR! gyp 還出現請看 node-gyp

方法 1 不行,就試試方法 2

您好,有試過還是無法安裝CLI...

dante iT邦新手 5 級 ‧ 2022-11-18 00:33:02 檢舉

peace&love
nodejs, npm, node-sass ,angular 的完整版本是多少?

我現在重灌Mac後,新開的專案可以安裝CLI了...(原本壞掉的還是不行)
但現在就把舊專案的內容搬到新開的專案中XD....

1

可以試試改用 yarn 來安裝試試。
另外先注意一下版本的問題。

其實安裝過程大多會警告你。多多注意一下有出現黃色字的。
我有時NPM安裝一直碰到版本的問題。(該用新版不用,不該用新版給我更新)

我現在都改用 yarn 來安裝了。

但我降低npm版本了還是無法安裝CLI,
這樣用yarn還可能解決問題嗎??

0
海綿寶寶
iT邦大神 1 級 ‧ 2022-11-16 22:11:50

參考這篇看有沒有幫助

另外
沒有什麼問題是重新安裝MacOS才能解決的
與其重新安裝MacOS
不如再買一台新的Mac/MBP/MBA

謝謝提供的文章!感覺很像但照著做後還是無法安裝CLI...

0
柴柴
iT邦新手 5 級 ‧ 2022-11-18 23:31:55

我之前也有遇過類似問題,我是把Node降到v12才解決的

我要發表回答

立即登入回答