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
e a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js. npm ERR! code 1 npm ERR! path E:\code\infopublicassess-web\node_modules\node-sass npm ERR! command failed npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node scripts/build.js npm ERR! Building: D:\codeApp\nodejs\node.exe E:\code\infopublicassess-web\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library= npm ERR! gyp info it worked if it ends with ok npm ERR! gyp verb cli [ npm ERR! gyp verb cli 'D:\\codeApp\\nodejs\\node.exe', npm ERR! gyp verb cli 'E:\\code\\infopublicassess-web\\node_modules\\node-gyp\\bin\\node-gyp.js', npm ERR! gyp verb cli 'rebuild', npm ERR! gyp verb cli '--verbose', npm ERR! gyp verb cli '--libsass_ext=', npm ERR! gyp verb cli '--libsass_cflags=', npm ERR! gyp verb cli '--libsass_ldflags=', npm ERR! gyp verb cli '--libsass_library=' npm ERR! gyp verb cli ] npm ERR! gyp info using node-gyp@7.1.2 npm ERR! gyp info using node@16.15.0 | win32 | x64 npm ERR! gyp verb command rebuild [] npm ERR! gyp verb command clean [] npm ERR! gyp verb clean removing "build" directory npm ERR! gyp verb command configure [] npm ERR! gyp verb find Python Python is not set from command line or npm configuration npm ERR! gyp verb find Python Python is not set from environment variable PYTHON npm ERR! gyp verb find Python checking if "python3" can be used npm ERR! gyp verb find Python - executing "python3" to get executable path npm ERR! gyp verb find Python - "python3" is not in PATH or produced an error npm ERR! gyp verb find Python checking if "python" can be used npm ERR! gyp verb find Python - executing "python" to get executable path npm ERR! gyp verb find Python - executable path is "D:\codeApp\Python313\python.exe" npm ERR! gyp verb find Python - executing "D:\codeApp\Python313\python.exe" to get version npm ERR! gyp verb find Python - version is "3.13.5" npm ERR! gyp info find Python using Python version 3.13.5 found at "D:\codeApp\Python313\python.exe" npm ERR! gyp verb get node dir no --target version specified, falling back to host node version: 16.15.0 npm ERR! gyp verb command install [ '16.15.0' ] npm ERR! gyp verb install input version string "16.15.0" npm ERR! gyp verb install installing version: 16.15.0 npm ERR! gyp verb install --ensure was passed, so won't reinstall if already installed npm ERR! gyp verb install version is already installed, need to check "installVersion" npm ERR! gyp verb got "installVersion" 9 npm ERR! gyp verb needs "installVersion" 9 npm ERR! gyp verb install version is good npm ERR! gyp verb get node dir target node version installed: 16.15.0 npm ERR! gyp verb build dir attempting to create "build" dir: E:\code\infopublicassess-web\node_modules\node-sass\build npm ERR! gyp verb build dir "build" dir needed to be created? E:\code\infopublicassess-web\node_modules\node-sass\build npm ERR! gyp verb find VS msvs_version not set from command line or npm config npm ERR! gyp verb find VS VCINSTALLDIR not set, not running in VS Command Prompt npm ERR! gyp verb find VS unknown version "undefined" found at "C:\Program Files\Microsoft Visual Studio\2022\Community" npm ERR! gyp verb find VS could not find a version of Visual Studio 2017 or newer to use npm ERR! gyp verb find VS looking for Visual Studio 2015 npm ERR! gyp verb find VS - not found npm ERR! gyp verb find VS not looking for VS2013 as it is only supported up to Node.js 8 npm ERR! gyp ERR! find VS npm ERR! gyp ERR! find VS msvs_version not set from command line or npm config npm ERR! gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt npm ERR! gyp ERR! find VS unknown version "undefined" found at "C:\Program Files\Microsoft Visual Studio\2022\Community" npm ERR! gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use npm ERR! gyp ERR! find VS looking for Visual Studio 2015 npm ERR! gyp ERR! find VS - not found npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8 npm ERR! gyp ERR! find VS npm ERR! gyp ERR! find VS ************************************************************** npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload. npm ERR! gyp ERR! find VS For more information consult the documentation at: npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows npm ERR! gyp ERR! find VS ************************************************************** npm ERR! gyp ERR! find VS npm ERR! gyp ERR! configure error npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use npm ERR! gyp ERR! stack at VisualStudioFinder.fail (E:\code\infopublicassess-web\node_modules\node-gyp\lib\find-visualstudio.js:121:47) npm ERR! gyp ERR! stack at E:\code\infopublicassess-web\node_modules\node-gyp\lib\find-visualstudio.js:74:16 npm ERR! gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (E:\code\infopublicassess-web\node_modules\node-gyp\lib\find-visualstudio.js:351:14) npm ERR! gyp ERR! stack at E:\code\infopublicassess-web\node_modules\node-gyp\lib\find-visualstudio.js:70:14 npm ERR! gyp ERR! stack at E:\code\infopublicassess-web\node_modules\node-gyp\lib\find-visualstudio.js:372:16 npm ERR! gyp ERR! stack at E:\code\infopublicassess-web\node_modules\node-gyp\lib\util.js:54:7 npm ERR! gyp ERR! stack at E:\code\infopublicassess-web\node_modules\node-gyp\lib\util.js:33:16 npm ERR! gyp ERR! stack at ChildProcess.exithandler (node:child_process:406:5) npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:527:28) npm ERR! gyp ERR! stack at maybeClose (node:internal/child_process:1092:16) npm ERR! gyp ERR! System Windows_NT 10.0.22631 npm ERR! gyp ERR! command "D:\\codeApp\\nodejs\\node.exe" "E:\\code\\infopublicassess-web\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library=" npm ERR! gyp ERR! cwd E:\code\infopublicassess-web\node_modules\node-sass npm ERR! gyp ERR! node -v v16.15.0 npm ERR! gyp ERR! node-gyp -v v7.1.2 npm ERR! gyp ERR! not ok npm ERR! Build failed with error code: 1 npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\kmxxg_123\AppData\Local\npm-cache\_logs\2025-07-01T08_25_48_985Z-debug-0.log
最新发布
07-02
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值