Stylus Loader has been initialized using an options object that does not match the API schema.

最近在练习一个项目,给一个组件中添加样式之后输入yarn serve启动项目就会提示:

40% building 157/165 modules 8 active ...\3.vue\vuecli_test\vue-app3\node_modules\vue-loader\lib\index.js??vue-loader-options!F:\vuecli_test\vue-app3\src\pages\Search\Search.vue?vue&type=template&id
98% after emitting CopyPlugin

 ERROR  Failed to compile with 1 errors                                                                                                                                                                                            16:27:10

 error  in ./src/components/FooterGuide/FooterGuide.vue?vue&type=style&index=0&lang=stylus&rel=stylesheet%2Fstylus&

Module build failed (from ./node_modules/stylus-loader/dist/cjs.js):
ValidationError: Invalid options object. Stylus Loader has been initialized using an options object that does not match the API schema.
 - options has an unknown property 'preferPathResolver'. These properties are valid:
   object { stylusOptions?, sourceMap?, webpackImporter?, additionalData? }
    at validate (F:\vuecli_test\vue-app3\node_modules\stylus-loader\node_modules\schema-utils\dist\validate.js:104:11)
    at Object.stylusLoader (F:\vuecli_test\vue-app3\node_modules\stylus-loader\dist\index.js:24:29)

 @ ./node_modules/vue-style-loader??ref--11-oneOf-1-0!./node_modules/css-loader/dist/cjs.js??ref--11-oneOf-1-1!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src??ref--11-oneOf-1-2!./node_modules
/stylus-loader/dist/cjs.js??ref--11-oneOf-1-3!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/FooterGuide/FooterGuide.vue?vue&type=style&index=0&lang=stylus&rel=style
sheet%2Fstylus& 4:14-491 14:3-18:5 15:22-499
 @ ./src/components/FooterGuide/FooterGuide.vue?vue&type=style&index=0&lang=stylus&rel=stylesheet%2Fstylus&
 @ ./src/components/FooterGuide/FooterGuide.vue
 @ ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=script&lang=js&
 @ ./src/App.vue?vue&type=script&lang=js&
 @ ./src/App.vue
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://192.168.1.116:8080&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.js

首先!先检查在style中,styl文件的引入对不对,按住Ctrl看能否进入文件,不能的话应该是因为文件引入导致的这个问题,前几天我遇到过一次,如果不是这个问题,可以试试下面的方法:

在其中有一行很关键的的提示:ValidationError: Invalid options object. Stylus Loader has been initialized using an options object that does not match the API schema.

可以确定问题出在了stylus-loader上,朋友告诉我应该是这个依赖有问题,让我重装一下,试了试不行,然后就尝试着换了一下stylus-loader的版本,装了个3.0.2版本的再启动就可以了!!

困扰我一天的问题终于解决了。,虽然不知道为什么最新版本的不行,但是这个版本还是不影响后面的开发,希望这个方法也可以帮助到被困扰的别的小伙伴们!

猜你喜欢

转载自blog.csdn.net/qq_44647809/article/details/109602651
今日推荐