nodejs16.15.0版本完美解决node-sass和sass-loader版本冲突问题

看我的版本:
在这里插入图片描述
问题在现:使用命令npm install sass-loader出错

! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: smoore-mes-web@1.4.0
npm ERR! Found: webpack@3.12.0
npm ERR! node_modules/webpack
npm ERR! dev webpack@"^3.6.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer webpack@"^4.36.0 || ^5.0.0" from sass-loader@10.3.1
npm ERR! node_modules/sass-loader
npm ERR! dev sass-loader@"^10.0.1" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!

这个是node-sass和sass-loader版本不对应造成,经过无数次踩坑后终于试出以下版本不冲突:

"node-sass": "^7.0.1"
"sass-loader": "^7.3.1"

步骤:

1) npm install node-sass@7.0.1 --save-dev
2) npm install sass-loader@7.3.1 --save-dev
3) npm install
4) npm run dev

即可成功启动
解析
在这里插入图片描述

  • 因为安装的是Node16所以node-sass的版本就得6.0+,但是我试了node-sass6.0+版本都解决不了,就升级到了7.0+
  • sass-loader版本找不到对应关系表,我就从高版本开始尝试,,出错就降版本

搞了好久才解决记录一下,希望能帮到你们。

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 unknown version "undefined" found at "D:\Program Files\Microsoft Visual Studio\2022\Community" gyp ERR! find VS unknown version "undefined" found at "D:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools" 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 (D:\迅雷下载\mayidaijia-xiaochengxu_1.0.1\node_modules\node-gyp\lib\find-visualstudio.js:121:47) gyp ERR! stack at D:\迅雷下载\mayidaijia-xiaochengxu_1.0.1\node_modules\node-gyp\lib\find-visualstudio.js:74:16 gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (D:\迅雷下载\mayidaijia-xiaochengxu_1.0.1\node_modules\node-gyp\lib\find-visualstudio.js:351:14) gyp ERR! stack at D:\迅雷下载\mayidaijia-xiaochengxu_1.0.1\node_modules\node-gyp\lib\find-visualstudio.js:70:14 gyp ERR! stack at D:\迅雷下载\mayidaijia-xiaochengxu_1.0.1\node_modules\node-gyp\lib\find-visualstudio.js:372:16 gyp ERR! stack at D:\迅雷下载\mayidaijia-xiaochengxu_1.0.1\node_modules\node-gyp\lib\util.js:54:7 gyp ERR! stack at D:\迅雷下载\mayidaijia-xiaochengxu_1.0.1\node_modules\node-gyp\lib\util.js:33:16 gyp ERR! stack at ChildProcess.exithandler (node:child_process:406:5) gyp ERR! stack at ChildProcess.emit (node:events:527:28) gyp ERR! stack at maybeClose (node:internal/child_process:1092:16) gyp ERR! System Windows_NT 10.0.26100 gyp ERR! command "D:\\MyApp\\nodejs\\node.exe" "D:\\迅雷下载\\mayidaijia-xiaochengxu_1.0.1\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library=" gyp ERR! cwd D:\迅雷下载\mayidaijia-xiaochengxu_1.0.1\node_modules\node-sass gyp ERR! node -v v16.15.1 gyp ERR! node-gyp -v v7.1.2
03-17
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 unknown version "undefined" found at "D:\Program Files\Microsoft Visual Studio\2022\Community" gyp ERR! find VS unknown version "undefined" found at "D:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools" 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 (D:\A_NEW_FILE\mp-weixin\mayidaijia-xiaochengxu_1.0.1\node_modules\node-gyp\lib\find-visualstudio.js:121:47) gyp ERR! stack at D:\A_NEW_FILE\mp-weixin\mayidaijia-xiaochengxu_1.0.1\node_modules\node-gyp\lib\find-visualstudio.js:74:16 gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (D:\A_NEW_FILE\mp-weixin\mayidaijia-xiaochengxu_1.0.1\node_modules\node-gyp\lib\find-visualstudio.js:351:14) gyp ERR! stack at D:\A_NEW_FILE\mp-weixin\mayidaijia-xiaochengxu_1.0.1\node_modules\node-gyp\lib\find-visualstudio.js:70:14 gyp ERR! stack at D:\A_NEW_FILE\mp-weixin\mayidaijia-xiaochengxu_1.0.1\node_modules\node-gyp\lib\find-visualstudio.js:372:16 gyp ERR! stack at D:\A_NEW_FILE\mp-weixin\mayidaijia-xiaochengxu_1.0.1\node_modules\node-gyp\lib\util.js:54:7 gyp ERR! stack at D:\A_NEW_FILE\mp-weixin\mayidaijia-xiaochengxu_1.0.1\node_modules\node-gyp\lib\util.js:33:16 gyp ERR! stack at ChildProcess.exithandler (node:child_process:406:5) gyp ERR! stack at ChildProcess.emit (node:events:527:28) gyp ERR! stack at maybeClose (node:internal/child_process:1092:16) gyp ERR! System Windows_NT 10.0.26100 gyp ERR! command "D:\\MyApp\\nodejs\\node.exe" "D:\\A_NEW_FILE\\mp-weixin\\mayidaijia-xiaochengxu_1.0.1\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library=" gyp ERR! cwd D:\A_NEW_FILE\mp-weixin\mayidaijia-xiaochengxu_1.0.1\node_modules\node-sass gyp ERR! node -v v16.15.1 gyp ERR! node-gyp -v v7.1.2
03-17
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值