10

I installed the latest version of node-sass in my react app but I got this error

"./src/index.scss (./node_modules/css-loader/dist/cjs.js??ref--5-oneOf-6-1!./node_modules/postcss-loader/src??postcss!./node_modules/resolve-url-loader??ref--5-oneOf-6-3!./node_modules/sass-loader/dist/cjs.js??ref--5-oneOf-6-4!./src/index.scss)
Node Sass version 6.0.1 is incompatible with ^4.0.0 || ^5.0.0."

My Json file :

{
  "name": "new-project-to",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "cra-template": "1.1.2",
    "node-sass": "^6.0.1",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-scripts": "4.0.3"
  },

I've checked some solutions on StackOverflow like npm install node-sass@4.14.1 but it didn't work?

What do you think guys?

David Jay
  • 345
  • 1
  • 2
  • 15

6 Answers6

2

Update your sass-loader like this: npm i sass-loader@latest

pzrq
  • 1,626
  • 1
  • 18
  • 24
Soloh
  • 99
  • 3
  • 10
2

Can you try editing the package.json to read


"dependencies": {
  "node-sass": "^5.0.0",
  ...
},
...

and then run npm i

Hope that helps, but it may not if Armuth's solution didn't work...

WR49
  • 21
  • 2
1

updating your react-scripts to the latest version should fix the problem.

Richard Torcato
  • 2,504
  • 25
  • 26
1

updating sass using 'npm i sass-loader@latest' and 'npm audit fix' worked for me.

  • you can try also (check answers): https://stackoverflow.com/questions/64625050/error-node-sass-version-5-0-0-is-incompatible-with-4-0-0 – Paulo Henrique Oct 09 '21 at 01:52
1

You must restart npm start wish you luck:)

mahdi
  • 21
  • 2
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 18 '21 at 16:26
1

This worked

To install the working node-sass version, you can use

npm uninstall node-sass
npm install node-sass@4.14.1

You can choose your version number based on the following table, based on the node version you are using which you can check by the command node --version

node-sass compatibility table

I hope it helps you

Abraham
  • 12,140
  • 4
  • 56
  • 92