问题
npm install 时,node-gyp 提示异常 gyp: No Xcode or CLT version detected!
分析
提示信息表明,未检测到Xcode或 Command Line Tools。首先确认Command Line Tools
是否安装,
Command Line Tools
中包含了很多有用的工具,比如LLVM
编译器。
使用llvm-gcc --version
来查看版本。
如果没安装,继续安装
通过xcode-select --install
安装
安装时可能会提示如下信息
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
有以上提示信息后,通过xcode-select --print-path
找到安装位置,通常在/Library/Developer/CommandLineTools
文件夹下,若不在可通过xcode-select -s /Library/Developer/CommandLineTools
将其更改。
修改安装位置
xcode-select -s /Library/Developer/CommandLineTools
删除并重新安装
rm -rf /Library/Developer/CommandLineTools
安装有两种方式
a. xcode-select --install
b. 通过developer.apple.com/download/al… 手动下载安装【推荐】
结束
安装之后再次执行npm install
,问题解决。