npm安装错误-没有检测到Xcode或CLT版本?

时间:2020-08-07 10:52:36

标签: angular npm-install package.json macos-catalina

“在'/'找不到'com.apple.pkg.cltools_executables'的收据”

在MacOS(Catalina)的VS Code bash终端中为angular 9项目运行'npm install'时抛出以上错误

Package.json依赖项:

    "@angular/animations": "~9.1.1",
    "@angular/common": "~9.1.1",
    "@angular/compiler": "~9.1.1",
    "@angular/core": "~9.1.1",
    "@angular/platform-browser": "~9.1.1",
    "@angular/platform-browser-dynamic": "~9.1.1",
    "@angular/router": "~9.1.1",
    "rxjs": "~6.5.4",
    "tslib": "1.10.0",
    "zone.js": "0.10.2"

2 个答案:

答案 0 :(得分:5)

请按照以下步骤操作:

  • 查找命令行工具的路径 xcode-select --print-path

  • 删除命令行工具目录(可以从上述步骤中检索目录路径) sudo rm -rf /Library/Developer/CommandLineTools

  • 运行此程序以重新安装 xcode-select --install

发布此信息后,“ npm install”应该可以在MacOS bash终端中的VS Code上成功运行。

答案 1 :(得分:1)

我整天都在跳动,我添加了1个npm软件包,整个本地网站都坏了。

似乎无法更新npm或yarn,并且我的本地站点无法正常工作。

我在这里尝试了第一个答案,删除了CommandLineTools并重新安装它们,但是最终我会收到一条消息,提示所请求的软件不在此服务器上。

因此,请转到:“关于本机”,然后选择“更新软件”,然后有CommandLine工具的更新。

按照提示操作,我的系统正在更新。

enter image description here

这是我得到的错误日志。

Python.app/Contents/MacOS/Python"
gyp info spawn /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
gyp info spawn args [
gyp info spawn args   '/usr/local/Cellar/node/14.5.0/libexec/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/Me/Projects/guavo/frontend/node_modules/fibers/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/Cellar/node/14.5.0/libexec/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/Me/Library/Caches/node-gyp/14.5.0/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/Me/Library/Caches/node-gyp/14.5.0',
gyp info spawn args   '-Dnode_gyp_dir=/usr/local/Cellar/node/14.5.0/libexec/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/Me/Library/Caches/node-gyp/14.5.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/Me/Projects/guavo/frontend/node_modules/fibers',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
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 (/usr/local/Cellar/node/14.5.0/libexec/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (events.js:314:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)
gyp ERR! System Darwin 19.6.0
gyp ERR! command "/usr/local/Cellar/node/14.5.0/bin/node" "/usr/local/Cellar/node/14.5.0/libexec/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release"
gyp ERR! cwd /Users/Me/Projects/guavo/frontend/node_modules/fibers
gyp ERR! node -v v14.5.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
node-gyp exited with code: 1
Please make sure you are using a supported platform and node version. If you
would like to compile fibers on this machine please make sure you have setup your
build environment--
Windows + OS X instructions here: https://github.com/nodejs/node-gyp
Ubuntu users please run: `sudo apt-get install g++ build-essential`