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

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

有什么问题吗?


当需要一个完整的常规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 /内容/应用开发者

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

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

这对我很管用(git)。

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

我在尝试使用npm安装包时遇到了一个问题。 我得到了错误:“sudo xcode-select -s /Applications//Xcode.app/Contents/Developer/”

要解决这个问题

我打开Xcode。 首选项 位置 选择命令林工具:Xcode 6.1.1

现在当用npm安装包时,我不再会得到错误。

没有Xcode:创建文件/usr/local/bin/xcodebuild的内容来欺骗XcodeSelect

  #!/bin/bash
  exit 0

Chmod +x /usr/local/bin/xcodebuild

XCode2: sudo Xcode -select -s /应用程序/Xcode\ 2.app/内容/开发者

注意“\”以避开空格

以防你使用xcode beta版:

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

我安装了两个Xcode实例。App和xcode-beta.app 当我试图用netbeans创建一个构建时,它向我显示了错误 支持的xcode版本和命令行工具没有找到netbeans

我遵循了以下步骤:

"xcode-select——print-path" = "/Applications/Xcode.app/Contents/Developer" " / / xcode /内容/应用开发人员/平台/ iPhoneSimulator。平台”的存在 "xcodebuild -version"以"Xcode"开头

after 1我发现它指向我到xcode-beta.app

下面是一个神奇的解决方案:

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

Xcode >首选项>位置>命令行工具

选择与你的Xcode版本匹配的选项。

从App Store下载Xcode。 进入Xcode首选项/位置/CommandlineTools 你只需要设置成Xcode版本。它自动指向" /Application/ xcode。app "

只需运行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 -s /Applications/Xcode 10.app/Contents/Developer

languoguangs-iMac:/ languoguang$ sudo xcode-select -s /Applications/Xcode 10.app/Contents/Developer
xcode-select: error: invalid argument '10.app/Contents/Developer'
Usage: xcode-select [options]

Print or change the path to the active developer directory. This directory
controls which tools are used for the Xcode command line tools (for example, 
xcodebuild) as well as the BSD development commands (such as cc and make).

Options:
  -h, --help                  print this help message and exit
  -p, --print-path            print the path of the active developer directory
  -s <path>, --switch <path>  set the path for the active developer directory
  --install                   open a dialog for installation of the command line developer tools
  -v, --version               print the xcode-select version
  -r, --reset                 reset to the default command line tools path
languoguangs-iMac:/ languoguang$ sudo xcode-select -s "/Applications/Xcode 10.app/Contents/Developer"

因为我在应用程序中的Xcode名称是Xcode 10,

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

的工作原理。

我在高海拔地区也遇到了同样的问题。 运行下面的命令可以解决这个问题

npm explore npm -g -- npm install node-gyp@latest

今天是2019年1月28日。

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

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

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

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

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

而不是

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

我得先运行这个

sudo xcode-select --reset

then

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

然后就成功了。

就我而言,

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 

这对我很管用。

以上这些方法对我都没用。我最初单独安装了命令行工具,然后是所有的Xcode。对我有用的是卸载如下所示的命令行工具。然后,当再次尝试运行xcode-select时,我被要求重新安装它们。

*顺便说一下,我发现这个线程的原因是因为我用macports安装了一些库(特别是gcc),大概是用旧的命令行工具,然后我在开发中途安装了完整的Xcode。所以无论如何,对于我的情况,我必须在删除独立的命令行工具后重新安装macports,重新安装它们,重新安装gcc,然后我的编译工作。

只需要两个步骤,和完整的XCode。App根本不需要:

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

此时弹出“Installing software”对话框:

就是这样!

我无需安装完整的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-select

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

请按以下步骤操作:

最新版本的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

在你的终端中输入这个

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

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

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

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

以上的解决方案都对我没有帮助。我在做一个老项目,我的电脑上安装了最新版本的NodeJs (v14.x)。

不支持10.1以上的节点版本。x为我工作,测试时,我收到了相同的错误上面。

解决方案

我安装了“n”,这是一个nodeJs版本管理器,比如nvm 我把我的nodeJs版本降级到9.x NPM安装现在工作了。

我现在需要更新我的版本,或者在package.json中指定我的节点版本。

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

sudo xcode-select --reset

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

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

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