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

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

有什么问题吗?


当前回答

只需运行sudo xcode-select -r即可自动重置路径。

 -r, --reset
              Unsets any user-specified developer directory, so that the developer directory will be found via the default search mechanism. This command must  be
              run with superuser permissions (see sudo(8)), and will affect all users on the system.

其他回答

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

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

在你的终端中输入这个

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

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

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

这对我很管用(git)。

手动安装Command LineTool对我来说很有效。

我在App Store中暂停了xcode 仍然无法下载Homebrew 我通过链接手动安装命令行工具。 砰砰砰

https://developer.apple.com/download/more/?=command%20line%20tools

对我来说最简单的解决方法就是拖放Xcode。应用程序从当前位置(在我的情况下,它在下载)到应用程序。