每次我尝试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
sudo xcode-select --reset
对我有用。
即使您安装了它们(我的情况),但通过升级到 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: No Xcode or CLT version detected 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 工具了。无需重新安装任何东西。
我想,到目前为止,您可能已经尝试了多种解决方案,但如果这些解决方案都没有为您工作,请不要担心 - 我明白了。 :)
非工作解决方案:
xcode-select --install 对我不起作用(macOS Catalina 10.15.7),因为它显示了一个软件更新对话框,上面写着无法安装软件,因为它目前无法从软件更新服务器获得。我还从 Apple 的下载网站 (https://developer.apple.com/download/more/?=for%20Xcode) 下载并安装了 Xcode 命令行工具,但问题以某种方式再次出现,或者可能没有解决首先,我不知何故没有注意到。 sudo xcode-select --reset 也没有为我解决问题。有人建议安装整个 XCode。不,谢谢。
工作解决方案:
这对我有用,即手动使用软件更新重新安装 Xcode 命令行工具。
使用以下命令检查要更新的软件列表中是否提到了命令行工具更新: softwareupdate -l 如果该列表中未提及命令行工具更新,则使用以下命令手动使其成为列表的一部分,该命令将创建一个临时文件: sudo touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress 通过再次运行 softwareupdate -l 验证列表现在是否包含命令行工具。现在,按 Cmd+Space 启动 Mac 的 Spotlight 搜索。搜索软件更新。启动软件更新。这将向您显示以下用于安装命令行工具的对话框。安装更新并快乐。 :) 删除在第 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
https://i.stack.imgur.com/oSBU3.png
我重新安装了命令行工具。
https://i.stack.imgur.com/qXKix.png
您需要找到安装目录。
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。但是删除并重新安装解决了这个问题。
卸载 xcode-select
sudo rm -rf $(xcode-select -print-path)
转到应用商店,然后下载 XCode。打开 XCode。在初始加载时,它将更新/安装东西。让这发生。从 Apple Developers 手动下载 Xcode 12 的命令行工具 安装 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 上:
使用命令 sudo rm -rf $(xcode-select --print-path) 卸载“Xcode 命令行工具”;在更多下载处为 Apple Developers 下载“Xcode 命令行工具”,然后安装它。
如果您根本不想安装 Xcode 命令行工具(就像我的情况一样)。
您可以尝试:
删除 package-lock.json 文件和 node_modules 目录(如果存在)和 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 又可以工作了
不定期副业成功案例分享
xcode-select --install
会打开安装对话框,但是当我同意条款并单击安装时,它会失败并显示:Can't install the software because it is currently not available from the Software Update Server
Can’t install the software because it is not currently available from the Software Update server
错误,并且不想安装 Xcode,正如@AHonarmand 链接的解决方案所建议的那样,只需从此处手动下载命令行工具 developer.apple.com/download/more/?=command%20line%20tools --这就是为我解决这个问题的原因。编辑:(来源:developer.apple.com/forums/thread/660641)