[Vue]解决less-loader 报错 TypeError: this.getOptions is not a function

问题

less-loader 报错 TypeError: this.getOptions is not a function at Object.lessLoader

Failed to compile.

./src/views/Login.vue?vue&type=style&index=0&id=26084dc2&lang=less&scoped=true& (./node_modules/css-loader/dist/cjs.js??ref--10-oneOf-1-1!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/src??ref--10-oneOf-1-2!./node_modules/less-loader/dist/cjs.js??ref--10-oneOf-1-3!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/Login.vue?vue&type=style&index=0&id=26084dc2&lang=less&scoped=true&)
Module build failed (from ./node_modules/less-loader/dist/cjs.js):
TypeError: this.getOptions is not a function
    at Object.lessLoader (F:\VS Code\Vue\supply\node_modules\less-loader\dist\index.js:21:24)

原因

因为 less-loader 版本太高问题,webpack和less-loader版本兼容问题导致的,需要降低版本。

解决

降低版本,安装指定版本:

npm uninstall less-loader

# npm install [email protected]  [email protected] -s
npm install [email protected]

猜你喜欢

转载自blog.csdn.net/weixin_43438052/article/details/114140449
今日推荐