繁体   English   中英

`npm install` 在 node-gyp 重建时失败,`gyp:未检测到 Xcode 或 CLT 版本!`

[英]`npm install` fails on node-gyp rebuild with `gyp: No Xcode or CLT version detected!`

每次我尝试npm install 我收到以下错误。 我如何解决它?

gyp: No Xcode or CLT version detected!

我在node -v → v8.8.0 & npm -v → v6.11.3

我尝试在 VSCode 终端和 iTerm 上运行它,但最终都出现了同样的错误。 (两者都更新到最新版本)。 我做的唯一新事情是将我的 macOS 更新到最新版本(今天是 Catalina 10.15.3)。

$ npm install          Fri Mar  6 17:22:40 2020

> fsevents@1.2.11 install /Users/synapse/Documents/synapsefi-dev-ui/node_modules/watchpack/node_modules/fsevents
> node-gyp rebuild

No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.

gyp: No Xcode or CLT version detected!
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/Users/synapse/.nvm/versions/node/v8.8.0/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:344:16)
gyp ERR! stack     at emitTwo (events.js:125:13)
gyp ERR! stack     at ChildProcess.emit (events.js:213:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Darwin 19.3.0
gyp ERR! command "/Users/synapse/.nvm/versions/node/v8.8.0/bin/node" "/Users/synapse/.nvm/versions/node/v8.8.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/synapse/Documents/synapsefi-dev-ui/node_modules/watchpack/node_modules/fsevents
gyp ERR! node -v v8.8.0
gyp ERR! node-gyp -v v5.0.3
gyp ERR! not ok
npm WARN synapsefi-dev-ui@2.0.20 No repository field.
npm WARN The package country-data is included as both a dev and production dependency.
npm WARN The package react-dropzone is included as both a dev and production dependency.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules/watchpack/node_modules/fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 install: `node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

即使您安装了它们(我的情况),但通过升级到 Catalina (10.15.*) 您可能会收到此错误(我的情况:))。

因此,简单地安装将无济于事,因为您将收到一个错误,表明它们已安装。

因此,您希望只需(I)重置工具或更糟糕的情况(II)再次卸载并安装(需要大量重新下载)(这是基于@Dane_duPlessis的回答)。

# just for а preview (not necessary)
xcode-select --print-path
# in my case it printed `/Library/Developer/CommandLineTools`

# could be useful if the path is making a problem
sudo xcode-select --switch /Library/Developer/CommandLineTools

# only for the (I) resetting case
sudo xcode-select --reset

# only for the (II) uninstalling case - the next line deletes folder returned by the `xcode-select --print-path` command
sudo rm -rf $(xcode-select --print-path)


# only for the (II) uninstalling case - install tools (again) if you don't get a default installation prompt
xcode-select --install

注意

  • 您不需要每个项目都这样做,但只需一次
  • 也有讨论说你必须在每次 OSX 更新时都这样做,在我的情况下,以后更新 OSX 系统并没有再次触发这个问题

致谢: gyp:未检测到 Xcode 或 CLT 版本 macOS Catalina

这适用于 macOS Catalina 版本 10.15.5:

$ xcode-select --print-path
/Applications/Xcode.app/Contents/Developer
$ sudo xcode-select --switch /Library/Developer/CommandLineTools
...
$ sudo xcode-select --reset
...

现在应该可以访问 xcode cli 工具了。 无需重新安装任何东西。

我想,到目前为止,您可能已经尝试了多种解决方案,但如果这些解决方案都没有为您工作,请不要担心 - 我明白了。 :)

非工作解决方案:

  1. xcode-select --install对我不起作用(macOS Catalina 10.15.7),因为它显示了一个 Software Update 对话框,上面写着Can't install the software because it is currently not available from the Software Update Server
  2. 我还从 Apple 的下载网站 ( https://developer.apple.com/download/more/?=for%20Xcode ) 下载并安装了 Xcode 命令行工具,但问题以某种方式再次出现,或者可能没有解决首先,我不知何故没有注意到。
  3. sudo xcode-select --reset也没有为我解决问题。
  4. 有人建议安装整个 XCode。 不,谢谢。

工作解决方案:

这对我有用,即手动使用软件更新重新安装 Xcode 命令行工具。

  1. 使用以下命令检查要更新的软件列表中是否提到了命令行工具更新: softwareupdate -l
  2. 如果该列表中未提及命令行工具更新,则使用以下命令手动使其成为列表的一部分,该命令将创建一个临时文件: sudo touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
  3. 通过再次运行softwareupdate -l来验证列表现在是否包含提到的命令行工具。
  4. 现在,按 Cmd+Space 启动 Mac 的 Spotlight 搜索。 搜索Software Update 启动Software Update
  5. 这将向您显示以下用于安装命令行工具的对话框。 安装更新并快乐。 :) 在此处输入图像描述
  6. 删除在第 2 步中创建的临时文件: sudo rm /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress

试试这些命令:

sudo rm -rf $(xcode-select -print-path)

xcode-select --install

如果上述方法没有解决您的问题,则可能是 Xcode 的安装路径有问题。 如有必要,请使用以下帮助。

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

sudo xcode-select --reset

我面临同样的问题错误信息

我重新安装了命令行工具。

重新安装

您需要找到安装目录。

xcode-select --print-path

删除现有安装:

sudo rm -r -f /Library/Developer/CommandLineTools

通过运行安装:

xcode-select --install

这对我有用

sudo xcode-select --reset

如果您的 Mac 已升级到macOS Catalina (10.15) ,则需要通过运行xcode-select --install来安装 XCode 命令行工具。 或者,如果你已经安装了完整的 Xcode,你可以在菜单Xcode → Open Developer Tool → More Developer Tools下找到它们。

大多数情况下,当有新的操作系统更新发生时,就会发生这种情况。 但我找到了解决这个问题的方法。 您需要按照以下步骤来解决。

通过删除以前安装的版本重新安装命令行工具。

step1:首先,获取安装的命令行工具的位置

xcode-select --print-path

上述命令 /Library/Developer/CommandLineTools 的结果

step2:删除文件夹

sudo rm -rf /Library/Developer/CommandLineTools

step3 - 再次安装

xcode-select --install

重新安装命令行开发工具后,当您从命令行运行任何 yarn 或 npm 命令时,gyp: No Xcode or CLT version detected 错误消息应该会消失。

您将需要安装 xcode 或命令行工具

运行xcode-select --install尝试安装,但失败并出现以下错误: Can't install the software because it is not currently available from the Software Update server. 这对我有用。

OS: Catalina 10.15.6
Xcode-select version: 2373

注意:在运行所有这些之前,我已经安装了 xcode-select 版本 2373。 但是删除并重新安装解决了这个问题。

  1. 卸载 xcode-select

sudo rm -rf $(xcode-select -print-path)

  1. 转到应用商店,然后下载 XCode。

  2. 打开 XCode。 在初始加载时,它将更新/安装东西。 让这发生。

  3. 从 Apple Developers 手动下载Xcode 12 的命令行工具

  4. 安装 CLT for Xcode 12 包。

你现在应该可以走了。

当我将 node-gyp 作为依赖项安装并在脚本中运行时,这发生在我身上。

一旦我在全球范围内安装它

npm i -g node-gyp

有效! (大苏尔)

在 catalina 我做了以下事情:

xcode-select --print-path
sudo rm -rf /Library/Developer/CommandLineTools

而且由于安装命令不起作用,我不得不从以下位置下载它: https ://developer.apple.com/download/more/

从那里安装:

XCode 12
Command Line Tools for XCode 12

发布删除现有 node_modules 并通过npm install重新安装的帖子。 有效。

当项目需要节点版本10但我有12+时,我遇到了同样的错误

xcode-select --print-path

上面应该给出: /Library/Developer/CommandLineTools

sudo rm -r -f /Library/Developer/CommandLineTools
xcode-select --install

我正是这样做的,我的问题现在已经消失了。 首先: xcode-select --print-path它给出了路径/Library/Developer/CommandLineTools

所以:

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

它会弹出安装窗口,只需安装即可。

感谢 Stackoverflow!

在 catalina 上,必须从https://developer.apple.com/download/more/手动安装 xcode 的命令行工具

在 macOS Catalina 上:

  1. 使用命令sudo rm -rf $(xcode-select --print-path)卸载“Xcode 命令行工具”;
  2. More Downloads for Apple Developers下载“Xcode 命令行工具”,然后安装它。

如果您根本不想安装 Xcode 命令行工具(就像我的情况一样)。

您可以尝试:

  1. 删除package-lock.json文件和node_modules目录(如果存在)
  2. npm i再次

它执行时会发出一些关于未检测到 Xcode 或 CLI 版本的 gyp 警告,但工作正常

我更新到 Big Sur 并在 Catalina 一切正常时收到此错误。 但我升级了 xcode 并安装在另一个文件夹中。

安装在一切正常的那个文件夹中帮助了我

使用 sudo 运行以下命令以重置命令行工具。

sudo xcode-select --reset

就我而言,我删除了 package.lock.json 并且它起作用了,我已经安装了 xCode

我尝试了一切,但没有任何效果。 就个人而言,即使问题是 gyp,也是 Next 的问题。 所以我降级了我的 node.js 版本。 安装 next.js 并返回到最新版本。

这些答案都不适合我,因为我安装了损坏的 XCode,一旦我卸载,npm 又可以工作了

在 Monterey,我通过 AppStore 安装了 Xcode,而不是通过命令行。

所以 Xcode 安装在路径“/Applications/Xcode.app/”(或“/Applications/Xcodex.xxapp”)

但是xcode-select --print-path指向“/Library/Developer/CommandLineTools”

这个命令固定

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

然后

npm install
npm rebuild

每个作品

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM