纱线安装失败,并带有node-sass / node-modules

问题描述

启用应用

使用自制程序将纱线更新为yarn v1.22.10,但随后yarn install失败,并出现以下错误

yarn install v1.22.10
[1/4] ?  Resolving packages...
[2/4] ?  Fetching packages...
[3/4] ?  Linking dependencies...
warning " > webpack-dev-server@3.11.0" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
warning "webpack-dev-server > webpack-dev-middleware@3.7.2" has unmet peer dependency "webpack@^4.0.0".
[4/4] ?  Building fresh packages...
[-/3] ⠈ waiting...
[-/3] ⠈ waiting...
error /Users/eliseserres/code/Septlieues/intranet/node_modules/node-sass: Command Failed.
Exit code: 1
Command: node scripts/build.js
Arguments: 
Directory: /Users/eliseserres/code/Septlieues/intranet/node_modules/node-sass
Output:
Building: /usr/local/Cellar/node/15.1.0/bin/node /Users/eliseserres/code/Septlieues/intranet/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 [
gyp verb cli   '/usr/local/Cellar/node/15.1.0/bin/node',gyp verb cli   '/Users/eliseserres/code/Septlieues/intranet/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 verb cli ]
gyp info using node-gyp@3.8.0
gyp info using node@15.1.0 | 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 "/usr/bin/python" in the PATH
gyp verb `which` succeeded /usr/bin/python /usr/bin/python
gyp verb check python version `/usr/bin/python -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: 15.1.0
gyp verb command install [ '15.1.0' ]
gyp verb install input version string "15.1.0"
gyp verb install installing version: 15.1.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: 15.1.0
gyp verb build dir attempting to create "build" dir: /Users/eliseserres/code/Septlieues/intranet/node_modules/node-sass/build
gyp verb build dir "build" dir needed to be created? /Users/eliseserres/code/Septlieues/intranet/node_modules/node-sass/build
gyp verb build/config.gypi creating config file
gyp verb build/config.gypi writing out config file: /Users/eliseserres/code/Septlieues/intranet/node_modules/node-sass/build/config.gypi
gyp verb config.gypi checking for gypi file: /Users/eliseserres/code/Septlieues/intranet/node_modules/node-sass/config.gypi
gyp verb common.gypi checking for gypi file: /Users/eliseserres/code/Septlieues/intranet/node_modules/node-sass/common.gypi
gyp verb gyp gyp format was not specified; forcing "make"
gyp info spawn /usr/bin/python
gyp info spawn args [
gyp info spawn args   '/Users/eliseserres/code/Septlieues/intranet/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/eliseserres/code/Septlieues/intranet/node_modules/node-sass/build/config.gypi',gyp info spawn args   '/Users/eliseserres/code/Septlieues/intranet/node_modules/node-gyp/addon.gypi',gyp info spawn args   '/Users/eliseserres/.node-gyp/15.1.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/eliseserres/.node-gyp/15.1.0',gyp info spawn args   '-Dnode_gyp_dir=/Users/eliseserres/code/Septlieues/intranet/node_modules/node-gyp',gyp info spawn args   '-Dnode_lib_file=/Users/eliseserres/.node-gyp/15.1.0/<(target_arch)/node.lib',gyp info spawn args   '-Dmodule_root_dir=/Users/eliseserres/code/Septlieues/intranet/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=.'
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 (/Users/eliseserres/code/Septlieues/intranet/node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! stack     at ChildProcess.emit (node:events:327:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:277:12)
gyp ERR! System Darwin 19.6.0
gyp ERR! command "/usr/local/Cellar/node/15.1.0/bin/node" "/Users/eliseserres/code/Septlieues/intranet/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/eliseserres/code/Septlieues/intranet/node_modules/node-sass
gyp ERR! node -v v15.1.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 

尝试更新node-sass,但yarn add node-sass失败,并出现相同的错误

node -v-> node v15.1.0

有人知道我该怎么办吗?

解决方法

根据this,您可能必须重新安装Xcode命令行工具,然后再配置node-gyp。我建议您按照本教程进行操作,因为它来自官方的Node.js开发人员。

,

仅node-sass v5支持节点15。由于我看到其中包含webpack,因此您可能会遇到与https://stackoverflow.com/a/64653160/455535相同的sass-loader不兼容