npm run serve Syntax Error: Error: Node Sass version 7.0.0 is incompatible with ^4.0.0.

created at 12-20-2021 views: 187

problem

When I started the project using npm, I reported the error of the inconsistent version of node-sass. After solving it for several hours, it was found that there was a problem with the version of node.

I downloaded the latest version of node 16.13.1 locally, downloaded and installed it normally, and then reported that the sass version was inconsistent during the build project

solution

1. Download the old version of node,

2. After the installation is complete, run the following command:

npm install node-sass@[version number]

Note: The version number you need is in the package.json file in the project, you will find it by directly searching for node-sass, and the version number can be consistent with it.

3. Then execute the following command:

npm rebuild node-sass@[version number]

4. Finally start the project:

npm run dev

Supplement: If sass-loader is not compatible, use npm uninstall sass-loader to uninstall, then reinstall, and specify the version number during installation.

created at:12-20-2021
edited at: 12-20-2021: