npm 安装报错解决 gyp: No Xcode or CLT version detected!

629 阅读1分钟

Xnip2021-12-21_11-22-17.jpg

gyp WARN EACCES user "guokai" does not have permission to access the dev dir "/Users/guokai/.node-gyp/14.18.2"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/var/folders/_4/nr7dx8m923dfgng9d2kdnlrm0000gn/T/.node-gyp"
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/lib/configure.js:345:16)
gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:282:12)
gyp ERR! System Darwin 21.2.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/cnpm/node_modules/npminstall/node-gyp-bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/guokai/Desktop/BAIDU/duseed/node_modules/_fsevents@1.2.13@fsevents
gyp ERR! node -v v14.18.2
gyp ERR! node-gyp -v v4.0.0
gyp ERR! not ok

使用命令修复

sudo xcode-select --install

提示

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

把 command-line tools 删除

sudo rm -rf $(xcode-select -p)
sudo rm -r -f /Library/Developer/CommandLineTools

重新安装

sudo xcode-select --install