Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Try to fix this error "Node Sass version 6.0.1 is incompatible with ^4.0.0 || ^5.0.0."

Tags:

sass

reactjs

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 [email protected] but it didn't work?

What do you think guys?

like image 446
David Jay Avatar asked Aug 08 '21 14:08

David Jay


People also ask

How do you fix error node Sass does not yet support your current environment?

Another approach to fix the “Node Sass does not yet support your current environment” error would be to downgrade your Node back to the version it was when node-sass worked. You could use the nvm use [node version] command to achieve this.

How do I check Sass version?

The “-v” command checks the version of SASS you have installed. If you don't have it installed, it will come back as not installed.

Why do I have to rebuild node sass?

To make node-sass available in your source code, npm needs to build the package and create a binding for your environment. When you change the version of Node. js used on your project, then the binding needs to be rebuild so that node-sass can be imported and executed from your code.


2 Answers

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...

like image 198
WR49 Avatar answered Oct 11 '22 06:10

WR49


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

like image 37
Soloh Avatar answered Oct 11 '22 04:10

Soloh