問題:
前端項目覆山,執(zhí)行npm install安裝包的時候會出現(xiàn)node-gyp的一下錯誤膳叨,如下所示
npm install
......
No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.
No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'.
No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.
gyp: No Xcode or CLT version detected!
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack at ChildProcess.emit (events.js:210:5)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Darwin 19.2.0
gyp ERR! command "/usr/local/Cellar/node/10.16.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/*/Project/*/node_modules/fsevents
gyp ERR! node -v v10.16.0
gyp ERR! node-gyp -v v6.0.1
gyp ERR! not ok
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules/fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 install: `node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
added 198 packages from 116 contributors and audited 362 packages in 6.487s
安裝參考 https://github.com/nodejs/node-gyp#on-macos茸俭,如果你的mac已經(jīng)升級到macOS Catalina (10.15)及以上粘都,請參考https://github.com/nodejs/node-gyp/blob/master/macOS_Catalina.md
- 1.在App Store中搜索安裝xcode
- 2.確保xcode命令行工具安裝正常不跟,通過如下命令驗證
/usr/sbin/pkgutil --packages | grep CL
// com.apple.pkg.CLTools_Executables應(yīng)該列出柒巫。如果不是励堡,則此測試失敗。
// 有輸出信息堡掏,驗證通過应结,比如
/ **
com.apple.pkg.CLTools_Executables
com.apple.pkg.CLTools_SDK_macOS1015
com.apple.pkg.CLTools_SDK_macOS1014
com.apple.pkg.CLTools_macOS_SDK
*/
/usr/sbin/pkgutil --pkg-info com.apple.pkg.CLTools_Executables
// version: 11.0.0(或更高版本)應(yīng)列出。如果不是泉唁,則此測試失敗鹅龄。
// 有輸出信息,驗證通過亭畜,比如
/ **
package-id: com.apple.pkg.CLTools_Executables
version: 11.3.1.0.1.1576735732
volume: /
location: /
install-time: 1579417091
groups: com.apple.FindSystemFiles.pkg-group
*/
// 如果兩項測試均成功扮休,則說明您已完成!您應(yīng)該已經(jīng)準(zhǔn)備好安裝node-gyp拴鸵。
// 如果任何一項測試失敗玷坠,則說明您的Xcode命令行工具安裝存在問題
- 3.檢查是否安裝Command Line Tools,在終端輸入
// 該命令也是安裝命令
xcode-select --install
// xcode-select: error: command line tools are already installed, use "Software Update" to install updates劲藐,表示已經(jīng)安裝過了
// 刪除重新安裝
sudo rm -rf /Library/Developer/CommandLineTools
// 執(zhí)行安裝八堡,此過程需要花費幾分鐘
xcode-select --install
可以參考 Xcode使用之安裝Xcode Command Line Tools
- 4.以上過程完成之后,重復(fù)第2步驗證
如果以上問題通過聘芜,再次執(zhí)行npm install就會安裝成功了