库克又搞事系列:gyp: No Xcode or CLT version detected!

大兔子大兔子 提交于 2021-01-07 18:40:54

问题

最近在macOS Catalina中使用npm安装模块,经常会出现如下错误:


> node-gyp rebuild

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.3.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/xxxx/Documents/temp/test001/node_modules/fsevents
gyp ERR! node -v v12.13.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok 
  • 截图如下

1

解决方案

1. 尝试用如下命令进行修复

$ xcode-select --install

系统提示如下信息:

xcode-select: error: command line tools are already installed, use "Software Update" to install updates

而事实上并没有所谓的"Software Update"可以更新

2. 正确姿势

一筹莫展之际,找到如下解决方案:

$ sudo rm -rf $(xcode-select -print-path)
$ xcode-select --install

请参见:

 
 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!