vue 项目使用 scss 升级 node v12 后报错 TypeError: this.getResolve is not a function

项目之前基于 node v8 创建,后来升级 node v12 后 node-sass 报错,执行 npm rebuild 同样报错。后来重新安装 node-sass 和 sass-loader 后出现如下错误。

error  in ./src/scss/app.scss

Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
TypeError: this.getResolve is not a function
    at Object.loader (G:\code\nideshop-admin-vue\node_modules\sass-loader\dist\index.js:52:26)

 @ ./src/scss/app.scss 4:14-220 14:3-18:5 15:22-228
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://192.168.1.123:9093/sockjs-node (webpack)/hot/dev-server.js ./src/main.js

使用 npm install --save sass-loader 安装的版本为 8.0 , 由于 8.0 版本移除了相关函数,导致出现 this.getResolve is not a function 错误。

sass-loader 8.0 版本更新信息如下:

move all sass (includePaths, importer, functions) options to the sassOptions option. The functions option can't be used as Function, you should use sassOption as Function to achieve this.

解决方法:降低 sass-loader 版本

npm uninstall sass-loader
npm install [email protected] --save-dev
发布了134 篇原创文章 · 获赞 401 · 访问量 162万+

猜你喜欢

转载自blog.csdn.net/sd19871122/article/details/104616669