「stylus和stylus-loader版本在Vue中的兼容问题」
报错代码
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 (E:\CODE\WebWorkspace\take-out\node_modules\stylus-loader\node_modules\schema-utils\dist\validate.js:104:11)
at Object.stylusLoader (E:\CODE\WebWorkspace\take-out\node_modules\stylus-loader\dist\index.js:24:29)
@ ./node_modules/vue-style-loader??ref--11-oneOf-1-0!./node_modules/@vue/cli-service/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/App.vue?vue&type=style&index=0&id=7ba5bd90&lang=stylus&scoped=true& 4:14-477 14:3-18:5 15:22-485
@ ./src/App.vue?vue&type=style&index=0&id=7ba5bd90&lang=stylus&scoped=true&
@ ./src/App.vue
@ ./src/main.js
解决方法
在package.json文件中对stylus和stylus-loader进行修改
"stylus-loader": "^3.0.1",
"stylus": "0.52.4"
回到终端窗口
npm install
之后 npm start 就可以解决了