'Dependencies installing fails on node-sass

Trying to install dependencies in a react project with

npm install

but it is failing giving the following error for node-sass and node-gyp enter image description here

OS: Ubuntu 20.04 Node version: 14.19.0 Tried with different node versions 17,16,14 and 12

Package.json is

   "@testing-library/jest-dom": "4.2.4",
   "@testing-library/react": "9.4.0",
   "@testing-library/user-event": "7.1.2",
   "downloadjs": "1.4.7",
   "jwt-decode": "2.2.0",
   "node-sass": "4.12.0",
   "react": "16.13.1",
   "react-dom": "16.13.1",
   "react-lottie": "1.2.3",
   "react-pdf": "4.1.0",
   "react-qr-code": "1.1.1",
   "react-scripts": "3.4.0",
   "react-slick": "0.28.1",
   "react-toastify": "6.0.8",
   "slick-carousel": "1.8.1"
 },```


Solution 1:[1]

First solution

Make sure your nodejs.js version is not superior than the latest stable version, which is currently v16.15.0. Then you would wanna use sass package instead of node-sass, as it's deprecated. For that do :

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

Second solution

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

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1