如何解决 Mac 上的 npm 安装错误
How to solve npm install errors on Mac
我为 Gatsby JS 网站在线购买了一个模板,当我尝试使用它时,它起作用了,但随后就停止了。我尝试在新目录中打开项目,但失败了。
目前我无法运行 npm install
项目,也不知道如何解决这个问题。
错误信息是:
npm ERR! code 1
npm ERR! path /Users/chistopherholder/Desktop/react_play/rewy-gatsby-with-strapi/rewy-api/node_modules/sharp
npm ERR! command failed
npm ERR! command sh -c (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
npm ERR! info sharp Using cached /Users/chistopherholder/.npm/_libvips/libvips-8.10.0-darwin-x64.tar.br
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@14.15.5 | darwin | x64
npm ERR! gyp info spawn /usr/bin/python2
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/Users/chistopherholder/Desktop/react_play/rewy-gatsby-with-strapi/rewy-api/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/chistopherholder/Desktop/react_play/rewy-gatsby-with-strapi/rewy-api/node_modules/sharp/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/chistopherholder/Desktop/react_play/rewy-gatsby-with-strapi/rewy-api/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/chistopherholder/.node-gyp/14.15.5/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/Users/chistopherholder/.node-gyp/14.15.5',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/Users/chistopherholder/Desktop/react_play/rewy-gatsby-with-strapi/rewy-api/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/Users/chistopherholder/.node-gyp/14.15.5/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/Users/chistopherholder/Desktop/react_play/rewy-gatsby-with-strapi/rewy-api/node_modules/sharp',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.
npm ERR!
npm ERR! No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'.
npm ERR!
npm ERR! No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.
npm ERR!
npm ERR! gyp: No Xcode or CLT version detected!
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack at ChildProcess.onCpExit (/Users/chistopherholder/Desktop/react_play/rewy-gatsby-with-strapi/rewy-api/node_modules/node-gyp/lib/configure.js:345:16)
npm ERR! gyp ERR! stack at ChildProcess.emit (events.js:315:20)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
npm ERR! gyp ERR! System Darwin 20.3.0
npm ERR! gyp ERR! command "/usr/local/bin/node" "/Users/chistopherholder/Desktop/react_play/rewy-gatsby-with-strapi/rewy-api/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /Users/chistopherholder/Desktop/react_play/rewy-gatsby-with-strapi/rewy-api/node_modules/sharp
npm ERR! gyp ERR! node -v v14.15.5
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/chistopherholder/.npm/_logs/2021-03-05T00_04_39_680Z-debug.log
我打开了debug.log,但是1787行代码我不太明白。
我也试过 sudo npm install
.
我该如何解决这些问题?
任何正确方向的提示都将不胜感激。我通常使用 django 而没有反应,所以我在这里有点无能为力。
这似乎不是解决问题的正确方法,但我很乐意有人解释解决此类问题的更好方法。
基本上我用brew卸载并重新安装了nodejs。
brew uninstall node
brew install node
brew cleanup
黎恩
npm install -g npm
然后将项目重置回开头并重新启动我的计算机。
现在可以使用了,但我不明白哪里出了问题,我确定我会 运行 再次解决这个问题。
也许我应该 运行在 Pipenv 中 shell
在每种情况下可能不是同一个问题,但每当我看到 npm ERR! gyp: No Xcode or CLT version detected!
时,我必须删除 xcode 并重新安装,然后错误就会消失。我最好的猜测是 Node and/or 导致冲突的 MacOs 更新问题。
遇到这种情况你可以先试试:
sudo xcode-select --reset
如果这不起作用(对我来说从来没有),您可以尝试:
sudo rm -rf $(xcode-select -print-path) && xcode-select --install
我为 Gatsby JS 网站在线购买了一个模板,当我尝试使用它时,它起作用了,但随后就停止了。我尝试在新目录中打开项目,但失败了。
目前我无法运行 npm install
项目,也不知道如何解决这个问题。
错误信息是:
npm ERR! code 1
npm ERR! path /Users/chistopherholder/Desktop/react_play/rewy-gatsby-with-strapi/rewy-api/node_modules/sharp
npm ERR! command failed
npm ERR! command sh -c (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
npm ERR! info sharp Using cached /Users/chistopherholder/.npm/_libvips/libvips-8.10.0-darwin-x64.tar.br
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@14.15.5 | darwin | x64
npm ERR! gyp info spawn /usr/bin/python2
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/Users/chistopherholder/Desktop/react_play/rewy-gatsby-with-strapi/rewy-api/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/chistopherholder/Desktop/react_play/rewy-gatsby-with-strapi/rewy-api/node_modules/sharp/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/chistopherholder/Desktop/react_play/rewy-gatsby-with-strapi/rewy-api/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/chistopherholder/.node-gyp/14.15.5/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/Users/chistopherholder/.node-gyp/14.15.5',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/Users/chistopherholder/Desktop/react_play/rewy-gatsby-with-strapi/rewy-api/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/Users/chistopherholder/.node-gyp/14.15.5/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/Users/chistopherholder/Desktop/react_play/rewy-gatsby-with-strapi/rewy-api/node_modules/sharp',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.
npm ERR!
npm ERR! No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'.
npm ERR!
npm ERR! No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.
npm ERR!
npm ERR! gyp: No Xcode or CLT version detected!
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack at ChildProcess.onCpExit (/Users/chistopherholder/Desktop/react_play/rewy-gatsby-with-strapi/rewy-api/node_modules/node-gyp/lib/configure.js:345:16)
npm ERR! gyp ERR! stack at ChildProcess.emit (events.js:315:20)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
npm ERR! gyp ERR! System Darwin 20.3.0
npm ERR! gyp ERR! command "/usr/local/bin/node" "/Users/chistopherholder/Desktop/react_play/rewy-gatsby-with-strapi/rewy-api/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /Users/chistopherholder/Desktop/react_play/rewy-gatsby-with-strapi/rewy-api/node_modules/sharp
npm ERR! gyp ERR! node -v v14.15.5
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/chistopherholder/.npm/_logs/2021-03-05T00_04_39_680Z-debug.log
我打开了debug.log,但是1787行代码我不太明白。
我也试过 sudo npm install
.
我该如何解决这些问题?
任何正确方向的提示都将不胜感激。我通常使用 django 而没有反应,所以我在这里有点无能为力。
这似乎不是解决问题的正确方法,但我很乐意有人解释解决此类问题的更好方法。
基本上我用brew卸载并重新安装了nodejs。
brew uninstall node
brew install node
brew cleanup
黎恩
npm install -g npm
然后将项目重置回开头并重新启动我的计算机。
现在可以使用了,但我不明白哪里出了问题,我确定我会 运行 再次解决这个问题。
也许我应该 运行在 Pipenv 中 shell
在每种情况下可能不是同一个问题,但每当我看到 npm ERR! gyp: No Xcode or CLT version detected!
时,我必须删除 xcode 并重新安装,然后错误就会消失。我最好的猜测是 Node and/or 导致冲突的 MacOs 更新问题。
遇到这种情况你可以先试试:
sudo xcode-select --reset
如果这不起作用(对我来说从来没有),您可以尝试:
sudo rm -rf $(xcode-select -print-path) && xcode-select --install