node.js - `npm install` 使用 `gyp: No Xcode or CLT version detected!` 在 node-gyp 重建时失败

标签 node.js npm terminal macos-catalina node-gyp

每次尝试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.*)你会得到这个错误(我的情况 :))。
因此,简单地安装无济于事,因为您将收到它们已安装的错误。
因此,您需要再次卸载并安装(需要 large redownload ):

xcode-select --print-path
# in my case /Library/Developer/CommandLineTools

# the next line deletes the path returned by the command above
sudo rm -rf $(xcode-select --print-path)

# install them (again) if you don't get a default installation prompt
xcode-select --install
注意 :
  • 您不需要每个项目都做一次,只需一次
  • 也有讨论说你必须在每次 OSX 更新时都这样做,在我的情况下,后来更新 OSX 系统没有再次触发这个问题

  • 致:gyp: No Xcode or CLT version detected macOS Catalina

    关于node.js - `npm install` 使用 `gyp: No Xcode or CLT version detected!` 在 node-gyp 重建时失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60573595/

    相关文章:

    node.js - 如何将 Node 应用程序的 "build"内容复制到名为 "dist"的文件夹

    python - 删除并替换在 Python 中打印到终端的最后一个字符

    bash - "if [ -t 1 ]"在 shell 脚本中做什么?

    node.js - 类型错误 : Client is not a constructor - error at the latest version of kafka-node

    javascript - Node 回调参数无法断言instanceof错误

    javascript - 将一个 ArrayBuffer 读/写/复制到另一个具有偏移量的 ArrayBuffer

    git - yarn 发布失败,因为 dist 文件夹已添加到 gitignore

    npm - 安装aws-cdk成功后,找不到cdk命令

    macos - 我可以将命令行脚本转换为 AppleScript 吗?

    node.js - Google App Engine,提供静态文件