NPM Error:gyp: No Xcode or CLT version detected!

问题

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

gyp info spawn args   '-Goutput_dir=.' ]
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 (/Users/kongfanyu/Downloads/mallplus-doc/mall-web-admin/node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Darwin 19.4.0
gyp ERR! command "/usr/local/bin/node" "/Users/kongfanyu/Downloads/mallplus-doc/mall-web-admin/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/kongfanyu/Downloads/mallplus-doc/mall-web-admin/node_modules/node-sass
gyp ERR! node -v v8.11.2
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 

解决方案

$ sudo rm -rf $(xcode-select -print-path)
$ xcode-select --install
发布了91 篇原创文章 · 获赞 43 · 访问量 14万+

猜你喜欢

转载自blog.csdn.net/kongfanyu/article/details/105639941