Syntax Error: ValidationError: Invalid options object. Sass Loader has been initialized using an opt

 

错误描述

使用 scss 样式后,项目启动时报错: Syntax Error: ValidationError: Invalid options object. Sass Loader has been initialized using an options object that does not match the API schema.

 

<style lang="scss" scoped>
a {
  target: '_blank';
}
</style>

 

 WAIT  Compiling...                                                                                                                                                                                                          下午7:15:20

98% after emitting CopyPlugin

 ERROR  Failed to compile with 1 error                                                                                                                                                                                       下午7:15:21

 error  in ./src/views/Index.vue?vue&type=style&index=0&id=23543608&lang=scss&scoped=true

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 'data'. These properties are valid:
   object { implementation?, sassOptions?, prependData?, sourceMap?, webpackImporter? }


 @ ./node_modules/vue-style-loader??ref--8-oneOf-1-0!./node_modules/@vue/cli-service/node_modules/css-loader/dist/cjs.js??ref--8-oneOf-1-1!./node_modules/vue-loader-v16/dist/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-v16/dist??ref--0-1!./src/views/Index.vue?vue&type=style&index=0&id=23543608&lang=scss&
scoped=true 4:14-481 15:3-20:5 16:22-489
 @ ./src/views/Index.vue?vue&type=style&index=0&id=23543608&lang=scss&scoped=true
 @ ./src/views/Index.vue
 @ ./src/router/index.ts
 @ ./src/main.ts
 @ multi (webpack)-dev-server/client?http://10.66.82.90:8080&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.ts

Issues checking in progress...
No issues found.


 WAIT  Compiling... 

 

 

Syntax Error: ValidationError: Invalid options object. Sass Loader has been initialized using an opt

 

 

 

报错原因

安装的 sass-loader 版本太高,造成 api 不兼容。

 

解决方案

cnpm uninstall --save sass-loader
cnpm install --save sass-loader@7.1.0

 

上一篇:开发 uni_modules 插件


下一篇:第一个vue程序