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

新手上路,请多包涵

每次我尝试 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

原文由 Jeena 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 586
2 个回答

即使您安装了它们(我的情况),但通过升级到 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

原文由 mPrinC 发布,翻译遵循 CC BY-SA 4.0 许可协议

这适用于 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 工具了。无需重新安装任何东西。

原文由 Dane_duPlessis 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题