我在网上为 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 一起工作并且没有反应,所以我在这里有点无能为力。
答案 0 :(得分:3)
在每种情况下可能都不是相同的问题,但是每当我看到 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
答案 1 :(得分:0)
这似乎不是解决问题的正确方法,但我希望有人解释解决此类问题的更好方法。
基本上我用 brew 卸载并重新安装了 nodejs。
brew uninstall node
brew install node
brew cleanup
赖恩
npm install -g npm
然后将项目重置回开始并重新启动我的计算机。
现在它可以工作了,但我不明白出了什么问题,我相信我会再次遇到这个问题。
也许我应该在 Pipenv shell 中运行它