Vue 中使用 less 报错 Module build failed: TypeError: loaderContext.getResolve is not a function

重述一下使用步骤

1、安装 npm install less less-loader --save

2、配置,在webpack.base.conf.js 的 rules 节点下新增:

 {
    test: /\.less$/,
    loader: "style-loader!css-loader!less-loader"
 }

3、使用,在 style 标签中使用 lang="less"

4、编译运行,此时可能会报错:

Module build failed: TypeError: loaderContext.getResolve is not a function

5、解决

这个错误一般都是由less-loader版本过高导致的,版本号可以在 package.json 中查看;

卸载原来的 npm uninstall less-loader;

安装指定版本 npm install [email protected] --save

6、编译运行

你可能感兴趣的:(前端)