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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM