Stylus| vue项目中stylus和stylus-loader版本兼容问题

Stylus| vue项目中stylus和stylus-loader版本兼容问题

报错代码:

in ./src/App.vue?vue&type=style&index=0&id=7ba5bd90&lang=stylus&scoped=true&

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 @ multi (webpack)-dev-server/client?http://192.168.1.102:8080&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.js

 

 

此时对应版本为 “stylus”: “^0.54.8”, “stylus-loader”: “^4.3.1”,

解决办法:更改版本号 stylus 0.54.5 stylus-loader 3.0.1 再重新安装依赖即可
npm install

看了好几个回答 似乎less和sass都同样有一样的问题,应该更改能用的版本就好了。

 

如何解决:

1.在package.json文件中增加如下代码:

"stylus-loader": "^3.0.1",
"stylus": "0.52.4",

2.然后回到命令窗口
输入

    $npm install

3.然后在输入

    $npm run dev

大功告成!!

posted on 2020-12-19 11:06  调皮小妮  阅读(1813)  评论(1编辑  收藏  举报