记录vue-cil安装scss时遇到的问题

执行npm install scss安装scss,但是报错
@ ./node_modules/vue-style-loader!./node_modules/css-loader?{“sourceMap”:true}!./node_modules/vue-loader/lib/style-compiler?{“vue”:true,“id”:“data-v-7ba5bd90”,“scoped”:false,“hasInlineConfig”:false}!./node_modules/sass-loader/dist/cjs.js?{“sourceMap”:true}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./src/App.vue 4:14-357 13:3-17:5 14:22-365
@ ./src/App.vue
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js
记录vue-cil安装scss时遇到的问题_第1张图片
能看出来是少安装了依赖,于是执行 npm install sass-loader --save-dev
但是报错
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
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@"^5.0.0" from [email protected]
npm ERR! node_modules/sass-loader
npm ERR! dev sass-loader@"*" 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!
npm ERR! See /Users/liuyifan/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/liuyifan/.npm/_logs/2022-02-14T13_02_29_493Z-debug.lo
看起来八成是版本问题,看到网上说npm 版本7要比版本6严格,所以决定把npm 降级到版本6,执行npm install npm@6 -g,npm成功降级,成功安装。但是依然会报错this.getOptions is not a function记录vue-cil安装scss时遇到的问题_第2张图片
八成还是版本问题,卸载sass-loader执行npm uninstall sass-loader
然后安装指定版本的[email protected][email protected]

npm install sass-loader@7.3.1 --save-dev
npm install node-sass@4.14.1 --save-dev

成功!
记录vue-cil安装scss时遇到的问题_第3张图片
记录vue-cil安装scss时遇到的问题_第4张图片
记录vue-cil安装scss时遇到的问题_第5张图片

你可能感兴趣的:(vue.js,scss,webpack)