vue的项目中使用lang=”less“在安装less-loader的时候经常会因为版本过高报错
Module build failed: TypeError: loaderContext.getResolve is not a function at createWebpackLessPlugin (C:UsersEDZDesktop sf_enterprise sf_enterprise ode_modulesless-loaderdistutils.js:31:33) at getLessOptions (C:UsersEDZDesktop sf_enterprise sf_enterprise ode_modulesless-loaderdistutils.js:148:31) at Object.lessLoader (C:UsersEDZDesktop sf_enterprise sf_enterprise ode_modulesless-loaderdistindex.js:29:49) @ ./node_modules/vue-style-loader!./node_modules/css-loader?{"sourceMap":true}!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-3d5f66de","scoped":true,"hasInlineConfig":false}!./node_modules/less-loader/dist/cjs.js?{"sourceMap":true}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./src/components/order/allOrder.vue 4:14-385 13:3-17:5 14:22-393 @ ./src/components/order/allOrder.vue @ ./src/router/index.js @ ./src/main.js @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js
通常是因为安装了最新版本的less-loader导致的。只需按照指定版本即可解决
npm i less-loader@4.1.0
问题解决好了OK