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

当前回答

我就是这么做的,我的问题现在没了。 第一: xcode-select——print-path 给出了path /Library/Developer/CommandLineTools

so:

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

它会弹出安装窗口,只要安装,你就可以上路了。

谢谢Stackoverflow !

其他回答

试试这些命令:

sudo rm -rf $(xcode-select -print-path)

xcode-select --install

如果以上没有解决你的问题,你可能是安装Xcode的路径有问题。如有必要,请使用以下方法。

sudo xcode-select --switch /Library/Developer/CommandLineTools

sudo xcode-select --reset

我也面临着同样的问题

我重新安装了命令行工具。

您需要找到安装目录。

xcode-select --print-path

删除现有安装:

sudo rm -r -f /Library/Developer/CommandLineTools

通过运行安装:

xcode-select --install

我猜,到目前为止,你可能已经尝试了多种解决方案,但如果这些解决方案都不适合你,别担心——我懂你的。:)

故障解决方案:

xcode-select --install didn't work for me (macOS Catalina 10.15.7) as it shows up a Software Update dialog box which says Can't install the software because it is currently not available from the Software Update Server. I also downloaded and install Xcode Command Line Tools from Apple's download website (https://developer.apple.com/download/more/?=for%20Xcode) but the problem re-appeared somehow or may be it didn't solve it in first place and I somehow didn't notice. sudo xcode-select --reset also didn't do the trick for me. Someone suggested to install whole XCode. No, thank you.

工作方案:

以下是对我有效的方法,即手动使用软件更新重新安装Xcode命令行工具。

Check if Command Line Tools Update is mentioned in your list of softwares to be updated by using following command: softwareupdate -l If Command Line Tools Update is not mentioned in that list, then manually make it part of the list using following command which will create a temporary file: sudo touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress Verify that the list now has the Command Line Tools mentioned by running softwareupdate -l again. Now, press Cmd+Space to initiate Mac's Spotlight Search. Search for Software Update. Start the Software Update. That will show you following kind of dialog for installing the Command Line Tools. Install away the update and be merry. :) Remove the temporary file created in Step 2: sudo rm /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress.

当我将node-gyp作为依赖项安装并在脚本中运行时,就发生了这种情况。

一旦我全局安装它

npm i -g node-gyp

它工作!(大苏尔)

当有新的操作系统更新时,大多数情况下都会发生这种情况。 但我找到了解决这个问题的办法。您需要按照以下步骤来解决。

通过删除以前安装的版本重新安装命令行工具。

step1:首先,获取已安装的命令行工具的位置

xcode-select --print-path

上面的命令/Library/Developer/CommandLineTools的结果

步骤2:删除文件夹

sudo rm -rf /Library/Developer/CommandLineTools

步骤3 -重新安装

xcode-select --install

通过重新安装命令行开发工具,当你从命令行运行任何yarn或npm命令时,gyp: No Xcode或CLT version detected错误消息应该会消失。