npm 报错 > gyp: No Xcode or CLT version detected!

由 月琳 发布 |149次浏览

遇到的问题

macOS Catalina 10.15.4中使用npm 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 (/.../node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! stack     at ChildProcess.emit (events.js:321:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Darwin 19.4.0
gyp ERR! command "/usr/local/Cellar/node/13.8.0/bin/node" "/.../node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /.../node_modules/node-sass
gyp ERR! node -v v13.8.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
Build failed with error code: 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 install: `node install`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

在网上找到的解决方法是sudo xcode-select --install来安装Command Line Tools ,但是我原本就已经安装了...至于安装完整的XCode?不干,这么大的一个IDE我才不安装。

再查找,原来是CommandLineTools的条款需要重新同意。

解决方法:

如果未安装Command Line Tools,直接安装即可:

sudo xcode-select --install

已经安装过Command Line Tools的,需要删除并重新安装,之后同意就可以了:

sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install

暂无评论

发表评论