上禮拜有更新angulr版本(不知道是不是這個原因),
結果開專案發現 npm run start 跑不起來了!!
後來嘗試重新安裝CLI,結果CLI卸載後也不能裝了!!!
而且我沒有用過python卻一直跟我說python有問題!
關鍵錯誤:
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降版
有人知道怎麼解決這個問題嗎@@??
完全不能寫程式了
把 npm 更新到最新版本看看
npm install -g npm@latest
先確定 angular 版本和需要的 nodejs 版本
看@angular/core/package.json 中的 engines
npm ERR! gyp
還出現請看 node-gyp
方法 1 不行,就試試方法 2
您好,有試過還是無法安裝CLI...
peace&love
nodejs, npm, node-sass ,angular 的完整版本是多少?
我現在重灌Mac後,新開的專案可以安裝CLI了...(原本壞掉的還是不行)
但現在就把舊專案的內容搬到新開的專案中XD....
可以試試改用 yarn 來安裝試試。
另外先注意一下版本的問題。
其實安裝過程大多會警告你。多多注意一下有出現黃色字的。
我有時NPM安裝一直碰到版本的問題。(該用新版不用,不該用新版給我更新)
我現在都改用 yarn 來安裝了。
參考這篇看有沒有幫助
另外
沒有什麼問題是重新安裝MacOS
才能解決的
與其重新安裝MacOS
不如再買一台新的Mac/MBP/MBA