Sass Loader 错误:无效的选项对象。Stylus Loader 已使用与 API 模式不匹配的选项对象进行初始化。

5

我运行npm run serve后出现了以下错误:

in ./src/components/site-checker/insert-model.vue?vue&type=style&index=0&lang=stylus&

Syntax Error: 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? }

我正在使用以下技术栈的VueJS框架:

[Vue 2] babel、router、vuex和Vue CLI v4.5.8。

1个回答

0

这是最近stylus-loadervue-cli之间兼容性问题的结果。它最近已在Vue的dev分支中修复

现在最好的选择是将stylus-loader降级到版本3。

npm install stylus-loader@3

您也可以尝试将vue-cli升级到最新版本:

npm update -g @vue/cli

或者

yarn global upgrade --latest @vue/cli


我在"package.json"文件旁边创建了"vue.config.js"文件。<pre> -------------------------------- module.exports = { module: { rules: [ { test: /.styl$/, loader: "stylus-loader", // 将Styl编译为CSS }, ], }, }; ---------------------------------- </pre> - moonris
我正在使用以下的编程工具:stylus-loader@4.3.1 + stylus@0.54.8 - moonris
那么问题是什么? - Dan
运行 npm run serve 后,我仍然得到相同的错误。 - moonris
我创建了一个全新的应用程序。但是在运行npm run serve之后,我遇到了相同的错误。因此,我将stylus-loader降级到版本3。然后错误消失了。 - moonris

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接