55

Using n to switch Node versions. I've ran yarn, npm rebuild node-sass --force many many times. And still fails. Getting this error:

Node Sass could not find a binding for your current environment

This usually happens because your environment has changed since running `npm install`.
Run `npm rebuild node-sass --force` to build the binding for your current environment.

Anyone have any idea how to fix?

Also.. When running this command..

npm rebuild node-sass --force

I get..

npm WARN using --force I sure hope you know what you are doing.

Doens't seem like it is doing anything..

GN.
  • 8,672
  • 10
  • 61
  • 126
  • What’s the rest of the error? There should be lots of output before that. – Ry- Nov 02 '18 at 20:17
  • 3
    Try to remove the entire `node_module` folder & reinstall it – felixmosh Nov 02 '18 at 20:18
  • Have you successfully built it before, or is this the first time? Also, what environment? Windows, Linux...? – Andy Nov 02 '18 at 20:27
  • I have encountered this before, specifically when moving from Windows to Linux. If this is the case, felixmosh is correct, but you need to run `npm cache clean` after deleting the `node_module` folder and before running `npm-install`. – Marvin WordWeaver Parsons Nov 02 '18 at 20:28
  • You mean “npm WARN using --force I sure hope you know what you are doing.” is the only line of output? Do you have `ignore-scripts=true` in your .npmrc? – Ry- Nov 03 '18 at 01:40
  • I don't have `ignore-scripts=true` – GN. Nov 03 '18 at 01:43
  • I've done these steps over and over again. Results in same error. So frustrating. – GN. Nov 03 '18 at 01:43
  • Which version of node do you have? `node -v`. I had a similar issue on OS X. Brew upgraded my version of node to 11. I solved it by ```sudo npm cache clean -f; sudo npm install -g n; sudo n 10.13.0 ``` – monk Nov 08 '18 at 19:57
  • Similar issue, but only when launching the project using webstorm (debug mode) Don't get why v11 is used while the node binary used is v8 – Vadorequest May 26 '19 at 11:54
  • I'd remove the entire node_modules folder and reinstall with `--no-bin-links` – chiliNUT Jul 17 '19 at 17:24
  • @GN. Did you manage this issue? I have the same thing with `node-sass` too – IC_ Sep 11 '19 at 02:14

12 Answers12

49

I did below to resolve the issue.

npm uninstall node-sass
npm i node-sass
npm rebuild node-sass
lennartk
  • 570
  • 1
  • 4
  • 15
antimatter
  • 855
  • 7
  • 10
17

remove node-sass from your command and just run npm rebuild --force

AS Mackay
  • 2,831
  • 9
  • 19
  • 25
user2240097
  • 311
  • 3
  • 11
13

If npm rebuild node-sass and npm rebuild node-sass --force doesn't work. Just uninstall node-sass and install again.

Fatimah
  • 722
  • 7
  • 16
12

I have tried all options like:

npm rebuild --force
npm rebuild node-sass --force
npm rebuild node-sass &

also did try to install through Python & updated VS Project links, but nothing worked..

EXCEPT running it manually:

node node_modules/node-sass/scripts/install.js 
MartenCatcher
  • 2,713
  • 8
  • 26
  • 39
Anusuya Goud
  • 161
  • 2
  • 9
12

The main issue is that your node-sass and node-npm versions are incompatible.

Please see the chart on this site or on this.

So my suggestion is either adjust your node-npm version or adjust node-sass.

In my case I was using node-sassof version 4.9.4 with node version 8.12.0 and npm version 6.4.1, It was working fine without any issue, later on I got new system and I had installed the latest node(12.16.0) & npm(6.13.4) and issue started so I dug into this and found above links.

Hope this will help you.

danronmoon
  • 3,814
  • 5
  • 34
  • 56
9

I just ran the command npm install node-sass and my issue was resolved.

Adnan Sheikh
  • 760
  • 3
  • 13
  • 27
5

remove package-lock.json file

remove node_modules folder

then remove from package.json it devDependencies

"node-sass": "4...",

then

npm i node-sass -D

and

npm i
NexGen
  • 131
  • 1
  • 3
  • After several hours of messing with this issue, removing node_modules and package-lock.json was all I needed to do. After that npm rebuild node-sass finally worked for me. – doubleya Aug 08 '20 at 03:24
  • Helped me, too. Thank you. I omitted step 3 (removing manually from `package.json`) and it still succeeded. – Uwe Keim Apr 09 '21 at 18:31
3

We are also facing the same issue many times, due to different versions of node and npm for numbers of web applications.

For that, we are just using the below command to take proper node-sass supported versions.

npm install node-sass or npm install node-sass -g

then try to rebuild the node-sass with,

npm rebuild node-sass or npm rebuild node-sass -f

After that all, if required then we can rebuild all packages and npm start or npm run watch and then the application is working properly.

Mihir Ajmera
  • 127
  • 1
  • 9
1

try this, add/modify your package.json

"node-sass": "*",

and run

npm install
Abhi Patel
  • 214
  • 1
  • 6
1

Uninstall and reinstall node-sass. Consider moving to dart sass because node-sass is now deprecated.

1

Switching Node version to 12.18.x worked for me.

Manas
  • 11
  • 4
  • The error said it found Binding for version 12.18.x, so when I switched to that node version it worked – Manas Jun 06 '21 at 17:55
1

I solved it with npm rebuild node-sass --force, in my case I had to do it as sudo