我在网上为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而不是react,所以我在这里有点无能为力。
在每种情况下可能都不是同样的问题,但每当我看到npm ERR! gyp: No Xcode or CLT version detected!
时,我必须删除xcode并重新安装,然后错误就消失了。我最好的猜测是这是Node和/或MacOs更新导致冲突的问题。
出现这种情况时,您可以先尝试:
sudo xcode-select --reset
如果这不起作用(对我来说从来没有),你可以试试:
sudo rm -rf $(xcode-select -print-path) && xcode-select --install
这似乎不是解决问题的正确方法,但我希望有人能解释一个更好的方法来解决这类问题。
基本上我卸载和重新安装nodejs与brew。
brew uninstall node
brew install node
brew cleanup
Rean
npm install -g npm
然后将项目重新设置为开始并重新启动计算机。
现在它可以工作了,但我不知道哪里出了问题,我相信我还会遇到这个问题。
也许我应该在Pipenv shell中运行