TypeError: this.getResolve is not a function

报错原因

对于一些旧的项目使用sass,sass-loader时会报错:TypeError: this.getResolve is not a function

找了一些资料说降低sass的版本,具体查了下,是一些旧的项目基于老的脚手架,webpack配置在4.x或3.x,而sass在8.x左右会要求必须webpack >=5.0,所以对于老旧项目降级就好了。

重新按版本安装:npm install sass@7.0.1

node-sass安装报错

sass分dart-sass和node-sass

node-sass 需要安装LibSass,经常被墙,建议直接安装sass(由Dart Sass编译而来)。

配置sass:

 
module.exports = {
  module: {
    rules: [
      {
        test: /.scss$/,
        use: [
          { loader: 'style-loader' },
          { loader: 'css-loader' },
          {
            loader: 'sass-loader',
            options: { implementation: require('sass') }
          }
        ]
      }
    ]
  }
}
 

版权声明:
作者:wuhou123
链接:https://wuhou.fun/35.html
来源:前端网
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
海报
TypeError: this.getResolve is not a function
报错原因 对于一些旧的项目使用sass,sass-loader时会报错:TypeError: this.getResolve is not a function 找了一些资料说降低sass的版本,……
<<上一篇
下一篇>>
文章目录
关闭
目 录