vue使用scss报错Module build failed: TypeError: this.getResolve is not a function at Object.loader 安装node

When building a vue scaffold or in a vue project, I want to use the function of sass (scss), and report an error Module build failed: TypeError: this.getResolve is not a function at Object.loader

  • Step 1: Install the following packages first:
npm install node-sass --save-dev //安装node-sass 
npm install sass-loader --save-dev //安装sass-loader 
npm install style-loader --save-dev //安装style-loader
  • Part 2: Lower the sass version
    After the installation of the above three packages is completed, the running project still
    Insert picture description here
    reports an error. This is because the current sass version is too high, and an error occurred during webpack compilation. At this time ,
    you only need to change to a lower version. Let’s talk about it. The modification method is very simple: find the package.json file and replace the version of "sass-loader" in it.

I "sass-loader": "^11.0.0"changed it locally to"sass-loader": "^7.3.1"

  • Step 3:npm install
    Save the sass version in the package file after reducing it, and then npm install. After completion, you can restart the project and run successfully.

  • Two more:
    Using the above method, I found an error again, saying that there are two packages of sass that are incompatible with 5.0.0 and 4.0.0, and then I found a 5.0.0 package inside, changed it to 4.0.0, and re-npm install ,Solve the problem.

reference:

Guess you like

Origin blog.csdn.net/weixin_45844049/article/details/113982990