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

首发于个人的csdn上: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 less@3.9.0  less-loader@5.0.0 -s
npm install less-loader@5.0.0
💥 一个正在学习全栈的 💥 ⭐ 精神小伙 ⭐ 💥 MelodyJerry 💥
posted @ 2021-02-26 16:56  MelodyJerry  阅读(2211)  评论(0编辑  收藏  举报
没有伞的孩子必须努力奔跑!|
载入天数...载入时分秒...
(っ•̀ω•́)っ✎⁾⁾ 开心每一天