每次我尝试npm安装。我得到以下错误。我该怎么解决呢?

gyp: No Xcode or CLT version detected!

我在节点-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

当前回答

在macOS Catalina上:

使用sudo rm -rf $(Xcode -select——print-path)卸载Xcode命令行工具; 在苹果开发者的更多下载中下载“Xcode命令行工具”,然后安装它。

其他回答

在我的情况下,我删除package.lock.json,它工作了,我已经安装了xCode

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

Xcode安装在“/Applications/Xcode”路径下。app/"(或"/Applications/ xcode .x.x. "应用程序”)

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

这个命令修复了

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

Then

npm install
npm rebuild

每一个作品

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

xcode-select --print-path

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

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

我更新到大苏尔,收到这个错误时,在卡特琳娜是一切正常。但是我升级了xcode并安装在另一个文件夹中。

安装在那个文件夹,一切都好,帮助我