正文
我的系统版本是 macOS Catalina 10.15.5。
最近在执行命令 cnpm 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/cnpm/node_modules/_node-gyp@3.8.0@node-gyp/lib/configure.js:345: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.5.0 gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/cnpm/node_modules/_npminstall@3.27.0@npminstall/node-gyp-bin/node-gyp.js" "rebuild" gyp ERR! cwd /Users/frankie/Desktop/Web前端/完整Demo/React项目/ReactDemo/node_modules/_fsevents@1.2.13@fsevents gyp ERR! node -v v12.13.1 gyp ERR! node-gyp -v v3.8.0 gyp ERR! not ok
然后网上搜查了一番,应该是 XCode 的问题。解决方法有两个:
1. 删除已经安装的 CommandLineTools。
$ sudo rm -rf $(xcode-select -p)
2. 重新安装,然后同意条款选择(我个人没尝试,因为 XCode 有 8.1G,不想安装)
$sudo xcode-select --install
我采用的是第一种方式,删除完再执行 cnpm install
,如下。很好,一个 ERROR 和 WARNING 都没有。
frankie@MacBook-Pro ReactDemo % cnpm install ✔ Installed 54 packages ✔ Linked 0 latest versions ✔ Run 0 scripts ✔ All packages installed (used 114ms(network 102ms), speed 0B/s, json 0(0B), tarball 0B)
我猜测原因可能是,最近从 10.14 升级到 10.15,然后因为部分第三方插件需要安装过 CommandLineTools,没有打开过该工具同意条款,然后出现这种问题的吧。(纯个人猜测,真正原因未证实)