当我尝试在我的本地安装vue商店前,但当我尝试“yarn install”命令时,我得到以下错误。如何解决这个错误?如何解决这个错误?

error /var/www/html/vue-storefront/node_modules/node-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments: 
Directory: /var/www/html/vue-storefront/node_modules/node-sass
Output:
Building: /usr/bin/node /var/www/html/vue-storefront/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/bin/node',
gyp verb cli   '/var/www/html/vue-storefront/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@13.9.0 | linux | 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/python3.6" in the PATH
gyp verb `which` succeeded /usr/bin/python3.6 /usr/bin/python3.6
gyp ERR! configure error 
gyp ERR! stack Error: Command failed: /usr/bin/python3.6 -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack                                ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack 
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:303:12)
gyp ERR! stack     at ChildProcess.emit (events.js:321:20)
gyp ERR! stack     at maybeClose (internal/child_process.js:1026:16)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
gyp ERR! System Linux 4.15.0-88-generic
gyp ERR! command "/usr/bin/node" "/var/www/html/vue-storefront/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /var/www/html/vue-storefront/node_modules/node-sass
gyp ERR! node -v v13.9.0

当前回答

对我来说,这个问题在升级到最新的v7.0.1后得到了解决。基于这个github问题,node-sass团队已经在7.0及以上版本中修复了它。

我使用的节点v16.13.2和苹果M1芯片。

其他回答

我将节点版本从16.0更改为14。X在我的包裹里。Json文件,它工作。

我现在在rails应用程序上也遇到了同样的问题,并通过升级webpacker来解决:

# check your Gemfile for version restrictions
bundle update webpacker

# overwrite your changes to the default install files and revert any unwanted changes from the install
rails webpacker:install

# yarn 1 instructions
yarn upgrade @rails/webpacker --latest
yarn upgrade webpack-dev-server --latest

见:https://github.com/rails/webpacker升级

chase439的道具:https://github.com/sass/node-sass/issues/2447

TBH,我的问题是我试图“npm install angular-cli”而不是“npm install @angular/cli”,希望这能帮助其他像我一样的傻瓜:)

我遇到了同样的问题,将node-sass版本升级为与node版本相同。用纱线刚跑完:

yarn add node-sass

这将升级版本并修复问题

在建议的决心之上,我发现有时纱线。Lock有一个node-sass的node-gyp锁定版本。 当我把它从3.8.0改到8.4.1时,一切都正常了。