node中node-sass安装失败解决

目前使用的node版本是v14.21.3,会自动安装相对应的npm版本
在这里插入图片描述

但是在 npm install的时候会出现各种报错,比如:

`gyp ERR! find VS
gyp ERR! find VS msvs_version not set from command line or npm config
gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR! find VS checking VS2017 (15.9.28307.1585) found at:
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools"
gyp ERR! find VS - "Visual Studio C++ core features" missing
gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
gyp ERR! find VS looking for Visual Studio 2015
gyp ERR! find VS - not found
gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
gyp ERR! find VS
gyp ERR! find VS **************************************************************
gyp ERR! find VS You need to install the latest version of Visual Studio
gyp ERR! find VS including the "Desktop development with C++" workload.
gyp ERR! find VS For more information consult the documentation at:
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
gyp ERR! find VS **************************************************************
gyp ERR! find VS
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Visual Studio installation to use
gyp ERR! stack     at VisualStudioFinder.fail (F:\java\project\dj-mall\renren-fast-vue\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
gyp ERR! stack     at F:\java\project\dj-mall\renren-fast-vue\node_modules\node-gyp\lib\find-visualstudio.js:74:16
gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (F:\java\project\dj-mall\renren-fast-vue\node_modules\node-gyp\lib\find-visualstudio.js:351:14)
gyp ERR! stack     at F:\java\project\dj-mall\renren-fast-vue\node_modules\node-gyp\lib\find-visualstudio.js:70:14
gyp ERR! stack     at F:\java\project\dj-mall\renren-fast-vue\node_modules\node-gyp\lib\find-visualstudio.js:372:16
gyp ERR! stack     at F:\java\project\dj-mall\renren-fast-vue\node_modules\node-gyp\lib\util.js:54:7
gyp ERR! stack     at F:\java\project\dj-mall\renren-fast-vue\node_modules\node-gyp\lib\util.js:33:16
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:390:5)
gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
gyp ERR! stack     at maybeClose (internal/child_process.js:1088:16)
gyp ERR! System Windows_NT 10.0.19045
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "F:\\java\\project\\dj-mall\\renren-fast-vue\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd F:\java\project\dj-mall\renren-fast-vue\node_modules\node-sass
gyp ERR! node -v v14.21.3
gyp ERR! node-gyp -v v7.1.2
gyp ERR! not ok
Build failed with error code: 1
npm WARN sass-loader@6.0.6 requires a peer of node-sass@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

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

npm ERR! A complete log of this run can be found in:
npm ERR!     F:\java\nodejs\node_cache\_logs\2023-12-02T12_44_17_955Z-debug.log`

这个原因是因为node-sass安装失败了

  1. 检查node-sass安装版本是否正确。

所以应该安装4.14+的
在项目中还没有package.json或者有package.json但是此文件没有指定node-sass的版本时,默认会安装node-sass的最新版本。由于安装的node版本时1,执行npm install node-sass命令默认安装了撰写本文时的node-sass最新版本8.0.0,所以会报错
安装


npm install node-sass@^4.14.0 --registry=https://registry.npm.taobao.org --sass_binary_site=https://npm.taobao.org/mirrors/node-sass/

参考:
https://blog.csdn.net/kingslave1/article/details/130526329

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

酱学编程

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值