首页 > 技术文章 > gyp: No Xcode or CLT version detected 在 macOS Catalina 错误解决办法

ljygirl 2021-02-24 13:41 原文

当我们在mac上使用Node.js 开发 使用 npm install 命令时候遇到上面的错误 

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:345:16)
gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Darwin 19.4.0

解决办法如下:

首先第一步,通过运行以下命令来获取已安装的命令行工具的位置

xcode-select --print-path

返回以下位置

第二步:我们将这个位置路径删除掉,通过以下命令进行删除

sudo rm -rf /Library/Developer/CommandLineTools

第三步:我们执行以下命令进行重新安装

xcode-select --install

点击安装,然后同意许可以继续安装,安装成功如下

然后们再执行Node命令,问题已解决

 

推荐阅读