vue2新项目sass 编译报错Invalid options object. Sass Loader has been initialized using an options object that does not match the API schema.

项目需要使用scss 的时候,编译报错    Invalid options object. Sass Loader has been initialized using an options object that does not match the API schema.

具体报错内容如下

Failed to compile with 1 error  

 error  in ./src/App.vue?vue&type=style&index=0&lang=scss&

Syntax Error: ValidationError: Invalid options object. Sass Loader has been initialized using an options object that does not match the API schema.
 - options has an unknown property 'prependDate'. These properties are valid:
   object { implementation?, sassOptions?, prependData?, sourceMap?, webpackImporter? }


 @ ./node_modules/vue-style-loader??ref--8-oneOf-1-0!./node_modules/css-loader/dist/cjs.js??ref--8-oneOf-1-1!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src??ref--8-oneOf-1-2!./node_modules/sass-loader/dist/cjs.js??ref--8-oneOf-1-3!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=style&index=0&lang=scss& 4:14-416 15:3-20:5 16:22-424
 @ ./src/App.vue?vue&type=style&index=0&lang=scss&
 @ ./src/App.vue
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://172.31.202.46:8080&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.js

报错原因是 sass-loader 版本搞了,查看自己 package.json ,需要降低版本,换成 V7版本就可以了

 

 

 解决方法:

npm install --save sass-loader@7.1.0
// 或者 ,测试通过两个
npm install --save sass-loader@7.0.1

 

posted @ 2022-04-29 10:41  zcm花开不败  阅读(6658)  评论(0编辑  收藏  举报