I'm using Node.js 16.13.1 and created a React application and try used Sass, but when I try to run it, I get this error:
Node Sass version 7.0.0 is incompatible with ^4.0.0 || ^5.0.0 || ^6.0.0
I figured out this issue using node-sass version 4.14.1 with the following commands.
With npm
npm uninstall node-sass
npm install node-sass@4.14.1
With yarn
yarn remove node-sass
yarn add node-sass@4.14.1
If you want to use SCSS and Sass in your React app, try to do this:
First remove node-sass:
yarn remove node-sass
If you use npm:
npm uninstall node-sass
Then install sass instead of node-sass:
yarn add -D sass
or
npm i -D sass
Finally your SCSS and Sass files will be correctly compiled!
node-sass is deprecated. Instead use sass.
You can uninstall the old and install the new one
npm uninstall node-sass
npm install sass
But if you prefer to use node-sass
You can use the following table to install the appropriate version node-sass for your installed node version which you can check by the command node --version
npm install node-sass@(your version)
You can simply do npm install node-sass@6.0.
This is because Node.js 16 is compatible with node-sass version 6.0.
I got the same issue. At the time of installing 'node-sass', my Node.js version is 15.
After downgrading node version node-12 and installed node-12 related 'node-sass' it's worked fine.
node -v
# Output: v15.2.0
nvm use 12.18.3
Now using node v12.18.3 (npm v6.14.6)
node -v
# Output: v12.8.3
npm install node-sass@4.14.1
To make sure it's working properly, add some abc.sass file. And write styles and import it on the component.
I got this error two months back. I tried each and every solution I can probably find.
Check whether you have created multiple React projects on the desktop. I did the same and started facing this issue. Combine all of them inside a single folder to get rid of the error. It worked for me. Please try this if you are making the same mistake.
i had the same problem with sass and i run this commands like below but none of them works.
npm uninstall node-sass
npm install sass
so finally i take a look at my package.json and i saw that i installed sass-loader so i'm uninstall and install that and the problem is fixed. you can use commands below for that.
npm uninstall sass-loader
npm install sass-loader
You can just switch to sass
in your package.json
"node-sass": "npm:sass@^1.49.9",
explanation
React still asks for node-sass after removing it and replacing with sass so you can alias it like this and now react will use sass