npm 安装依赖 报这个错时: gyp: No Xcode or CLT version detected!

今天接盘一个公司的项目,因为疫情原因,公司发不出工资,很多人都离开了,而我被迫留守,所以要接手离职同事的项目。

废话不多说,进入主题。

当我开心的拉完项目,准备装好依赖开始一顿debug操作时,发现.. 项目跑不动,报错说缺了node-sass模块,好吧,那就install一下,结果没装成功,基本可以确定是这个绊脚石害我跑不起来项目了。接着,先品一品报错内容,报错如下:


Building: /usr/local/bin/node /Users/money/work/dunming-ops-front/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [ '/usr/local/bin/node',
gyp verb cli   '/Users/money/work/dunming-ops-front/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library=' ]
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` succeeded python2 /usr/bin/python2
gyp verb check python version `/usr/bin/python2 -c "import sys; print "2.7.16
gyp verb check python version .%s.%s" % sys.version_info[:3];"` returned: %j
gyp verb get node dir no --target version specified, falling back to host node version: 10.7.0
gyp verb command install [ '10.7.0' ]
gyp verb install input version string "10.7.0"
gyp verb install installing version: 10.7.0
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version is already installed, need to check "installVersion"
gyp verb got "installVersion" 9
gyp verb needs "installVersion" 9
gyp verb install version is good
gyp verb get node dir target node version installed: 10.7.0
gyp verb build dir attempting to create "build" dir: /Users/money/work/dunming-ops-front/node_modules/node-sass/build
gyp verb build dir "build" dir needed to be created? /Users/money/work/dunming-ops-front/node_modules/node-sass/build
gyp verb build/config.gypi creating config file
gyp verb build/config.gypi writing out config file: /Users/money/work/dunming-ops-front/node_modules/node-sass/build/config.gypi
gyp verb config.gypi checking for gypi file: /Users/money/work/dunming-ops-front/node_modules/node-sass/config.gypi
gyp verb common.gypi checking for gypi file: /Users/money/work/dunming-ops-front/node_modules/node-sass/common.gypi
gyp verb gyp gyp format was not specified; forcing "make"
gyp info spawn /usr/bin/python2
gyp info spawn args [ '/Users/money/work/dunming-ops-front/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/money/work/dunming-ops-front/node_modules/node-sass/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/money/work/dunming-ops-front/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/money/.node-gyp/10.7.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/money/.node-gyp/10.7.0',
gyp info spawn args   '-Dnode_gyp_dir=/Users/money/work/dunming-ops-front/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/money/.node-gyp/10.7.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/money/work/dunming-ops-front/node_modules/node-sass',
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=.' ]
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/money/work/dunming-ops-front/node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:237:12)
gyp ERR! System Darwin 19.4.0
gyp ERR! command "/usr/local/bin/node" "/Users/money/work/dunming-ops-front/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/money/work/dunming-ops-front/node_modules/node-sass
gyp ERR! node -v v10.7.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
Build failed with error code: 1
npm WARN @intervolga/[email protected] requires a peer of webpack@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @vue/[email protected] requires a peer of webpack@>=4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of ajv@^6.9.1 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of webpack@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of webpack@>=4.0.0 < 6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of webpack@^4.4.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of webpack@^4.0.0 but none is installed. You must install peer dependencies yourself.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

仔细阅读一番,无果,因为还没遇到过这类问题,所以花了一个多小时搜了下,网上结论大都是更新xcode或者可以更新xcode的一个小组件,xcode-select。

最后选择重装xcode-select,因为xcode好几个g呢,下载完都天亮了。

注意事项:

要删了本地的xcode-select相关文件,一开始以为可以直接装,覆盖了,但是装不了,删了之后就可以了。

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

然后再安装之

 sudo xcode-select --install

装完之后再安装你想安装的依赖/模块,就可以啦!

最后吐槽下,sass这个老东西,发现接手的这个项目用的包,技术都不是我喜欢的简洁,快速方便。less就很香啊,不需要依赖ruby,直接装就好了,害我装这么多东西。只能说一下旧的历史遗留下来的东西好用但是麻烦,毕竟是过去的

你可能感兴趣的:(NPM)