在运行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。应用程序从当前位置(在我的情况下,它在下载)到应用程序。

从App Store安装Xcode。安装完成后,使用root权限运行xcodebuild,即sudo xcodebuild并接受该语言。在这个npm安装之后,bcrypt就像一个魅力!

只需运行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可以从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

就我而言,

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

因为我的Xcode有一些特殊的名字。如)Xcode_11.2.0_beta_2_stackoverflow.app

cd /applications
ls

然后我找到了我的Xcode名称,然后用

sudo xcode-select -s /Applications/{myXcodeName}.app/Contents/Developer 

这对我很管用。