在运行npm安装时看到以下错误,需要node-gyp…但可以被任何需要xcode-select的东西触发。
xcodebuild工具需要Xcode,但是是活动的 开发者目录'/Library/ developer /CommandLineTools'是一个命令 直线工具实例
有什么问题吗?
在运行npm安装时看到以下错误,需要node-gyp…但可以被任何需要xcode-select的东西触发。
xcodebuild工具需要Xcode,但是是活动的 开发者目录'/Library/ developer /CommandLineTools'是一个命令 直线工具实例
有什么问题吗?
当前回答
我得先运行这个
sudo xcode-select --reset
then
sudo xcode-select -switch /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.
我得先运行这个
sudo xcode-select --reset
then
sudo xcode-select -switch /Library/Developer/CommandLineTools
然后就成功了。
以上的解决方案都对我没有帮助。我在做一个老项目,我的电脑上安装了最新版本的NodeJs (v14.x)。
不支持10.1以上的节点版本。x为我工作,测试时,我收到了相同的错误上面。
解决方案
我安装了“n”,这是一个nodeJs版本管理器,比如nvm 我把我的nodeJs版本降级到9.x NPM安装现在工作了。
我现在需要更新我的版本,或者在package.json中指定我的节点版本。
我无需安装完整的Xcode应用程序就可以解决这个错误。但是,你必须安装xcode命令行工具。
从这里开始:
$ CD /usr/bin $ sudo mv xcodebuild xcodebuild。orig(以防万一的备份) $ vim xcodebuild 粘贴如下内容:
#!/bin/bash
if [[ $1 == '-version' ]]; then
echo "Xcode 10.2.1"
echo "Build version 10E1001"
else
/usr/bin/xcodebuild.bak $@
fi
$sudo chmod +x xcodebuild
只需要两个步骤,和完整的XCode。App根本不需要:
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
此时弹出“Installing software”对话框:
就是这样!