每次我try 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

推荐答案

即使你已经安装了它们(我的 case ),但是通过升级到Catalina(10.15.*)你可以得到这个错误(我的 case :).

因此,简单地安装是没有帮助的,因为你会得到一个错误,他们已经安装.

因此,希望你只需要使用(I) reset个工具,或者在更糟糕的情况下使用(II) uninstall and install个(需要102个)工具(这是基于@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

NOTE:

  • 你不需要每个项目都做,只需要做一次
  • 还有人讨论说,每次OSX更新都必须这样做,在我的情况下,后来更新OSX系统不会再次引发这个问题

学分:gyp: No Xcode or CLT version detected macOS Catalina

Node.js相关问答推荐

如何解决无法获得本地颁发者证书的问题

使用 NPM 8 安装本地构建

如何修复node.js中的错误代码无法加载资源:服务器响应状态为403(禁止)

错误:0308010C:try 通过 Github 推送部署到 firebase 托管时出现数字

使用 NPM 三个 mocha+typescript 进行测试

在将用作 nodejs/expressjs 中的中间件的函数中使用 keycloak.protect()

nvm / node / npm: node 12 的 npm 比 node 14 的更新?

nuxt:在 docker 镜像中找不到

Winston http 日志(log)级别的行为与 info 不同

当我们有esnext时,为什么我们需要nodenext typescript 编译器选项?

在 Express-js 中使用路由

通过 npm 导入 Sass

您如何写入 aws lambda 实例的文件系统?

异步函数 - 等待不等待promise

错误:大多数中间件(如 bodyParser)不再与 Express Bundle

如何可靠地散列 JavaScript 对象?

如何从命令行在 Node.js 上运行 Jasmine 测试

异步构造函数

Express js 阻止 GET /favicon.ico

CORS 错误:预检响应中的 Access-Control-Allow-Headers 不允许请求标头字段授权