Stylus| vue專案中stylus和stylus-loader版本相容問題

ML�發表於2020-12-13

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都同樣有一樣的問題,應該更改能用的版本就好了。

相關文章