Error: 'node-sass' version 5.0.0 is incompatible with ^4.0.0 Error: 'node-sass' version 5.0.0 is incompatible with ^4.0.0 reactjs reactjs

Error: 'node-sass' version 5.0.0 is incompatible with ^4.0.0


TL;DR

  1. npm uninstall node-sass
  2. npm install node-sass@4.14.1

Or, if using Yarn (default in newer CRA versions)

  1. yarn remove node-sass
  2. yarn add node-sass@4.14.1

Edit2: sass-loader v10.0.5 fixes it. The problem is you might not be using it as a project dependency, but more as a dependency of your dependencies. CRA uses a fixed version, angular-cli locks to node-sass v4, and so on.

The recommendation for now is: if you're installing just node-sass, check the below workaround (and the note). If you're working on a blank project and you can manage your Webpack configuration (not using CRA or a CLI to scaffold your project), install the latest sass-loader.


Edit: this error comes from sass-loader. There is a semantic versioning mismatch since node-sass @latest is v5.0.0 and sass-loader expects ^4.0.0.

There is an open issue on their repository with an associated fix that needs to be reviewed. Until then, refer to the solution below.


Workaround: don't install node-sass 5.0.0 yet (the major version was just bumped).

Uninstall node-sass

npm uninstall node-sass

Then install the latest version (before 5.0)

npm install node-sass@4.14.1


Note: LibSass (hence node-sass as well) is deprecated and dart-sass is the recommended implementation. You can use sass instead, which is a Node.js distribution of dart-sass compiled to pure JavaScript.

Be warned though:

Be careful using this approach. React-scripts uses sass-loader v8, which prefers node-sass to sass (which has some syntax not supported by node-sass). If both are installed and the user worked with sass, this could lead to errors on CSS compilation


The only one reason why you get some error like that, is because your Node.js version is not compatible with your node-sass version.

So, make sure to checkout the documentation at node-sass.

Or this image below will be help you in deciding what Node.js version can use the node-sass version.

Enter image description here

For an example, if you're using Node.js version 12 on your Windows system ("maybe"), then you should have to install the node-sass version 4.12.

npm install node-sass@4.12

Yeah, like that. So now you only need to install the node-sass version recommended by the node-sass team with Node.js version installed on your computer.


Uninstall node-sass:

npm uninstall node-sass

Use sass by:

npm install -g sassnpm install --save-dev sass