在运行npm安装时看到以下错误,需要node-gyp…但可以被任何需要xcode-select的东西触发。

xcodebuild工具需要Xcode,但是是活动的 开发者目录'/Library/ developer /CommandLineTools'是一个命令 直线工具实例

有什么问题吗?


当前回答

在你的终端中输入这个

xcode-select --install
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -license accept

其他回答

以防你使用xcode beta版:

sudo xcode-select -s /Applications/Xcode-Beta.app/Contents/Developer

如果你已经安装了XCode,你所要做的就是…

打开XCode 去Xcode >首选项>位置 从命令行工具选择你的XCode

对于那些不想安装Xcode的人,还有其他解决方案:

安装命令行工具(如果你还没有): xcode-select——安装 修改主目录: sudo xcode-select -switch /Library/Developer/CommandLineTools

这对我很管用(git)。

简单的重新安装xcode-select

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

如果你使用的是Xcode测试版,运行

sudo xcode-select --switch /Applications/Xcode-beta.app/Contents/Developer 

而不是

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer