在执行npm install 或者 vue create的时候报错出以下的错误:
> 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/yangjian/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
亲测该错误是由于升级了系统版本,但Command Line Tools
版本不兼容导致,需要卸载并重新安装,当然如果你没有XCODE理论上需要先安装XCODE。
// 删除
$ sudo rm -rf $(xcode-select -print-path)
# 可以先尝试这个第二条命令。但系统应该已经安装了。
$ xcode-select --install
如果卸载后安装时报出 不能安装该软件,因为当前无法从软件更新服务器获得
的错误,那么此时需要去苹果官网手动下载,下载文件为dmg文件,直接安装即可。
注意XCODE的版本和系统版本,我自己保证了XCODE版本一致,系统差一个小版本号,实际安装之后没有任何问题。