爆款云服务器低至4折,1核1G¥366/

项目之前基于 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 sass-loader@7.3.1 --save-dev

标签: Node.js, Vue