7

When I start my react project in Fedora 32 using command yarn start, it shows error like this:

./src/style/base.scss (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-5-1!./node_modules/postcss-loader/src??postcss!./node_modules/resolve-url-loader??ref--6-oneOf-5-3!./node_modules/sass-loader/dist/cjs.js??ref--6-oneOf-5-4!./src/style/base.scss)
Error: Node Sass does not yet support your current environment: Linux 64-bit with Unsupported runtime (93)
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v4.14.1

My current node version is:

[dolphin@MiWiFi-R4CM-srv]~/Documents/GitHub/react-admin% nvm list
        v8.17.0
       v10.24.1
->     v16.13.0
        v17.2.0
         system
default -> 8 (-> v8.17.0)

I have tried different version of node but did not fix this problem, why did this happen? what should I do to fix this problem? I did not found any package dependencies of node-sass in the package.json, this is the package.json file:

{
    "name": "react-admin",
    "version": "0.1.0",
    "private": true,
    "dependencies": {
        "@ant-design/compatible": "1.0.8",
        "animate.css": "^3.7.2",
        "antd": "^4.0.0",
        "axios": "^0.19.0",
        "braft-editor": "^2.3.8",
        "echarts": "^4.4.0",
        "is-core-module": "2.2.0",
        "moment": "2.29.1",
        "nprogress": "^0.2.0",
        "react": "^17.0.2",
        "react-dom": "^17.0.2",
        "react-highlight-words": "0.17.0",
        "react-loadable": "^5.5.0",
        "react-redux": "^7.1.1",
        "react-router-dom": "^5.1.1",
        "react-scripts": "^3.2.0",
        "redux": "^4.0.4",
        "redux-logger": "3.0.6",
        "redux-promise-middleware": "^6.1.2",
        "redux-thunk": "^2.3.0",
        "screenfull": "^5.0.0"
    },
    "scripts": {
        "start": "react-app-rewired start",
        "build": "CI=false && react-app-rewired build",
        "test": "react-app-rewired test",
        "eject": "react-scripts eject"
    },
    "eslintConfig": {
        "extends": "react-app"
    },
    "browserslist": {
        "production": [
            ">0.2%",
            "not dead",
            "not op_mini all"
        ],
        "development": [
            "last 1 chrome version",
            "last 1 firefox version",
            "last 1 safari version"
        ]
    },
    "husky": {
        "hooks": {
            "pre-commit": "lint-staged"
        }
    },
    "lint-staged": {
        "src/**/*.{js,jsx,ts,tsx,json,css,scss,md}": [
            "node_modules/.bin/prettier --write",
            "git add"
        ],
        "src/**/*.{css,scss,less,json,html,md,markdown}": [
            "node_modules/.bin/prettier --write",
            "git add"
        ]
    },
    "devDependencies": {
        "@babel/helper-builder-react-jsx": "^7.12.13",
        "babel-plugin-import": "^1.12.2",
        "customize-cra": "^0.8.0",
        "husky": "^3.0.9",
        "lint-staged": "^9.4.2",
        "sass": "1.37.0",
        "prettier": "^1.18.2",
        "react-app-rewired": "^2.1.4"
    }
}
Youssouf Oumar
  • 29,373
  • 11
  • 46
  • 65
Dolphin
  • 29,069
  • 61
  • 260
  • 539

3 Answers3

11

First solution

Make sure your node.js version is not superior to the recommended one. If not downgrade it, and for that, you could use n package from npm:

npm i -g n
n stable
# if one of the commands does not pass, you may need to use sudo
sudo npm install -g n
sudo n 14

Then you would wanna use sass package instead of node-sass, as it's deprecated. And for that run in your terminal:

npm uninstall node-sass --save
npm install sass --save

Second solution

If you need or want node-sass for some reason, you should downgrade your nodejs version to like v14. For that you can use n package from npm:

npm install -g n
n 14
# if one of the commands does not pass, you may need to use sudo
sudo npm install -g n
sudo n 14
Youssouf Oumar
  • 29,373
  • 11
  • 46
  • 65
5

This is a common node-sass version compatibility problem with the Node version.

Quick hack:

Uninstall and reinstall node-sass, and it will find the missing binary for itself.

npm uninstall --save-dev node-sass
npm install --save-dev node-sass

Permanent solution:

If the issue is not resolved using the above commands, there may be a problem with your node version. Check that your node version supports node-sass version. Chose a stable node version and repeat the above commands to fix this issue.

Below is the compatibility table of the node with node-sass:-

NodeJS | Supported node-sass version | Node Module
Node 19     8.0                         111
Node 18     8.0                         108
Node 17     7.0+                        102
Node 16     6.0+                        93
Node 15     5.0+                        88
Node 14     4.14+                       83
Node 13     4.13+, <5.0                 79
Node 12     4.12+                       72
Node 11     4.10+, <5.0                 67
Node 10     4.9+, <6.0                  64
Node 8      4.5.3+, <5.0                57
Node <8     <5.0                        <57

If the issue is still not fixed, check the node-sass supported environment's list:- https://github.com/sass/node-sass/releases/

Balram Singh
  • 1,576
  • 19
  • 30
  • 1
    uninstalling and reinstalling node-sass while on the specific node version, I wanted to use for my project which in my case was Node V18 worked for me. thanks @Balram Singh – Solomon Sunday Apr 19 '23 at 19:31
1

I ran into the same problem when deploying an already existing application.

And it helped me to downgrade the Node version.

When developing the application, Node v14.19.2 was used, version Node 16.18.0 was installed locally. node-sass has a dependency on the Node version according to the following scheme:

┌────┬─────────┬─────────────────────────────┬─────────────┐
│    │    A    │              B              │      C      │
├────┼─────────┼─────────────────────────────┼─────────────┤
│  1 │ NodeJS  │ Supported node-sass version │ Node Module │
│  2 │ Node 19 │ 8.0+                        │ 111         │
│  3 │ Node 18 │ 8.0+                        │ 108         │
│  4 │ Node 17 │ 7.0+, <8.0                  │ 102         │
│  5 │ Node 16 │ 6.0+                        │ 93          │
│  6 │ Node 15 │ 5.0+, <7.0                  │ 88          │
│  7 │ Node 14 │ 4.14+                       │ 83          │
│  8 │ Node 13 │ 4.13+, <5.0                 │ 79          │
│  9 │ Node 12 │ 4.12+, <8.0                 │ 72          │
│ 10 │ Node 11 │ 4.10+, <5.0                 │ 67          │
│ 11 │ Node 10 │ 4.9+, <6.0                  │ 64          │
│ 12 │ Node 8  │ 4.5.3+, <5.0                │ 57          │
│ 13 │ Node <8 │ <5.0                        │ <57         │
└────┴─────────┴─────────────────────────────┴─────────────┘

Based on the dependencies in the table, I installed Node version 14, which corresponds to the node-sass version from package.json and everything worked

"node-sass": "^4.14.1",

I tried to change the node-sass version, but I didn't succeed. I was able to solve the problem only by downgrading the Node version

Sometimes, after changing the Node version, you need to run the command:

npm rebuild node-sass