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

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

有什么问题吗?


当前回答

我只是运行了以下命令,问题为我解决了:

sudo xcode-select --reset

其他回答

当需要一个完整的常规Xcode时,Xcode -select developer目录指向/Library/ developer /CommandLineTools时发生此问题(当CommandLineTools安装在Xcode之后时发生)

解决方案:

如果你还没有Xcode,请安装它(从https://appstore.com/mac/apple/xcode获取)。 接受条款和条件。 确保Xcode app在/Applications目录下(不是/Users/{user}/Applications)。 使用以下命令将Xcode -select指向Xcode app Developer目录: sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

注意:确保你的Xcode应用路径是正确的。

Xcode: / / Xcode /内容/应用开发者 Xcode-beta: / / Xcode-beta.app /内容/应用开发者

今天是2019年1月28日。

在我的Mac上,我做了两件事来解决这个问题:

在终端运行如下命令: Sudo xcode-select——install 重启你的Mac。

直到我重新启动电脑,我的Android Studio一直出现这个问题。重启后,它工作得很好。还要注意,我没有像其他人那样执行任何——switch命令。我希望这能有所帮助。

我得先运行这个

sudo xcode-select --reset

then

sudo xcode-select -switch /Library/Developer/CommandLineTools

然后就成功了。

以防你使用xcode beta版:

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

请按以下步骤操作:

最新版本的Xcode可以从https://developer.apple.com/xcode/download/下载 除非另有说明,否则将在“下载”中下载。请确保检查你下载和提取Xcode的路径 现在不像其他下载的应用程序,在提取时,Xcode没有提供将其移动到应用程序的选项 注意XCODE-ACTUAL-LOCATION或将其移动到应用程序 注意你是否下载了Xcode或Xcode-beta

在4和5的基础上,执行其中一条命令(如果没有阅读上述说明,请不要执行所有命令):

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer
sudo xcode-select -s /[XCODE-ACTUAL-LOCATION]/Xcode.app/Contents/Developer
sudo xcode-select -s /[XCODE-ACTUAL-LOCATION]/Xcode-beta.app/Contents/Developer