132

I'm trying to do npm install and an error appears :

Failed at the node-sass@4.5.0 postinstall script.

I tried to delete node_modules and then reinstall it, same error appears. what will be the solution?

node v8.9.3
npm v5.4.2
ionic 3.19.0

Jaisa Ram
  • 1,687
  • 14
  • 21
Joe Sleiman
  • 2,416
  • 5
  • 25
  • 40

19 Answers19

166

Got the same problem (node v10.3.0, ionic 3.13.0). This worked :

  • Delete package-lock.json,
  • Delete node_modules folder,
  • Run npm install again.
Michaël Polla
  • 3,511
  • 3
  • 23
  • 37
  • 1
    It worked. Anyone who is having this issue should try this and I am also wondering that cleaning the cache without removing the whole folder should also work. – Sagar Khatri Jul 16 '19 at 09:05
  • Is package.backup.json a replacement for package-lock.json? I can't find package-lock.json in my ionic app folder – mykoman May 06 '20 at 21:48
57

try

sudo rm -rf package-lock.json node_modules
sudo npm cache clean --force
npm i --unsafe-perm node-sass
Zymotik
  • 6,412
  • 3
  • 39
  • 48
Jaisa Ram
  • 1,687
  • 14
  • 21
44

Just Try with this command hope it will very helpful. it's working for me

sudo npm install -g node-sass@4.5.0 --unsafe-perm=true --allow-root
Abhay Singh
  • 1,595
  • 1
  • 23
  • 40
26

rolling back to node v10.17.0 fixed the problem to me.

You can use nvm to do so:

https://github.com/nvm-sh/nvm

> nvm install 10.17.0
> nvm use 10.17.0
> node -v
10.17.0
solimanware
  • 2,952
  • 4
  • 20
  • 40
21

I also had to face the same problem with node v12.16.3.

  1. Remove node-sass dependency from your package.json if it is mentioned in your dependencies.This will allow npm to install other required dependencies without any disruption.

  2. Delete package-lock.json file and node_modules folder from your project.

  3. Force clean the entire NPM cache by using following comand.

    npm cache clean --force
    
  4. Re-Install all the dependencies.

    npm install
    
  5. Now you can install node-sass.

    npm i node-sass
    
Aravinda Meewalaarachchi
  • 2,551
  • 1
  • 27
  • 24
18

Node-sass@4.5.0 cannot be installed on node 8

enter image description here

Please update either node-sass or node version compatible

Go to https://github.com/sass/node-sass/releases to check which fits for you

amc software
  • 747
  • 1
  • 7
  • 18
6

use this flag --unsafe-perm=true

sudo npm i gulp-sass -ES --unsafe-perm=true
Ankit Sinha
  • 1,630
  • 1
  • 20
  • 19
4

Uninstall current npm and install lower versions, it is a common error if version didn't match, downgrading node/npm will mostly fix this kind of issues

npm install -g npm@4.6.1
Jayamurugan
  • 1,757
  • 2
  • 14
  • 34
3

After uninstalling node-sass try cleaning your npm cache. After that try installing node-sass again.

npm cache clean && npm install node-sass
3

The minimum version of node-sass that supports Node 8 is 4.5.3. You'll need to upgrade your node-sass or downgrade your Node version. Ionic may also have separate issues since it isn't a tested platform with node-sass.

nschonni
  • 4,069
  • 1
  • 28
  • 37
2

You should try to install SASS.

I remember havign this issue in AngularJS with compass, I had to install it with Ruby to make it work. This was 3 years ago, so I'm not sure this would be the solution, but it doesn't cost anything except time to try, right ?

  • pm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! node-sass@4.5.0 postinstall: `node scripts/build.js` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the node-sass@4.5.0 postinstall script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\jsleiman\AppData\Roaming\npm-cache\_logs\2018-01-17T10_13_04_021Z-debug.log – Joe Sleiman Jan 17 '18 at 10:13
  • Ok I give up. Good luck. –  Jan 17 '18 at 10:14
  • Installing sass globally worked for me. I still see the npm build errors but they seem to be ignored and npm install succeeds. – C.M. Dec 20 '19 at 16:21
2

I needed to take the following steps to "resolve" this problem:

  1. Create folder at the root: mkdir ~/safe_node_module;
  2. Download package wget -q https://github.com/sass/node-sass/releases/download/v4.13.0/linux-x64-72_binding.node and then send to the folder created in step 1;
  3. Set the export environment variable export SASS_BINARY_PATH=/home/ronaldaraujo/safe_node_module/linux-x64-72_binding.node;
  4. Install packages normally npm i;
Ronald Araújo
  • 1,395
  • 4
  • 19
  • 30
2

Install the higher version of node-sass

npm install node-sass@4.13.1
Vinay Somawat
  • 639
  • 14
  • 23
1

I had the same issue with a new install with Keystone.js. I was able to get pass this issue by removing Node Sass from package.json and running npm install again. Being that the package wasn't listed under node modules. And it worked fine after that.

Sebastian
  • 402
  • 3
  • 12
1

Solved this by force installing node-sass locally: npm install -f node-sass

I was pretty sure I knew what I was doing... this

saber tabatabaee yazdi
  • 4,404
  • 3
  • 42
  • 58
1

I'm trying to do npm install in the ionic project and an error appears

Failed at the node-sass@4.9.0 postinstall script.

The following steps worked for me ionic project

Remove npm than run the following commands

npm i

npm install @ionic/app-scripts@latest--unsafe-perm=true --allow-root

Rajnikant Lodhi
  • 530
  • 4
  • 13
0

Sometime unable to download file win32-x64-79_binding.node due to your proxy restrict to download so plase follow this below link set them manually. https://github.com/sass/node-sass/issues/2773

0

This works for me on Windows running Node.js version v14.17.3

npm install -g node-sass@4.5.0 --unsafe-perm=true --allow-root --force

Note: My node-sass version was node-sass@4.13.1. But the above command will work for other versions too. Just replace the node-sass version number in the above command with your required node-sass version.

Saabbir
  • 588
  • 6
  • 8
-1

The following steps worked for me

npm install -g node-sass@4.5.0 --unsafe-perm=true --allow-root

npm cache clean


npm install
Amit Joshi
  • 15,448
  • 21
  • 77
  • 141