39

I have a angular application: https://github.com/XBITSwitzerland/ngx-admin/tree/ng2-admin

And now I try to do: npm install

But I get this error (The compete Output of the command was way too long, so I just share here the last part):

gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\github\ngx-admin\node_modules\node-gyp\lib\build.js:258:23)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\github\\ngx-admin\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\github\ngx-admin\node_modules\wintersmith-sassy\node_modules\node-sass
gyp ERR! node -v v10.15.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Build failed with error code: 1
npm WARN ngx-toastr@4.4.1 requires a peer of @angular/core@^2.2.0 but none is installed. You must install peer dependencies yourself.
npm WARN ngx-toastr@4.4.1 requires a peer of @angular/common@^2.2.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\webpack-dev-server\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\watchpack\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@3.13.1 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@3.13.1 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\danyb\AppData\Roaming\npm-cache\_logs\2019-01-29T18_25_12_699Z-debug.log

Does someone have an Idea why this error occurs and how to solve it?

Sultan Aslam
  • 5,600
  • 2
  • 38
  • 44
BlockchainProgrammer
  • 1,999
  • 5
  • 20
  • 32

12 Answers12

65

If you run into this issue, read this page: https://www.bramvandenbulcke.be/en/kb/failed-node-sass3131-postinstall-script

The solution in my case:

1) Delete the package-lock.json file

2) npm install gulp-sass --save-dev

3) npm install node-sass@latest

Version specific notes:

node-sass@3.13.1 runs only on versions of Node.js up to v7 as stated in the release notes:

BlockchainProgrammer
  • 1,999
  • 5
  • 20
  • 32
20

I think this is happening because you're missing the node-sass module. Try the following and rerun your build script and see if this resolves your issue:

npm install node-sass@latest

Also, I see you're using fsevents on a Windows platform, just a warning this module is only supported for Native access to OS X FSEvents

Nathan
  • 7,853
  • 4
  • 27
  • 50
10

I had error node-sass@3.13.1 postinstall: node scripts/build.js on npm install after this message

> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v3.13.1/linux-x64-72_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v3.13.1/linux-x64-72_binding.node": 

HTTP error 404 Not Found

Hint: If github.com is not accessible in your location
      try setting a proxy via HTTP_PROXY, e.g. 

      export HTTP_PROXY=http://example.com:1234

or configure npm proxy via

      npm config set proxy http://example.com:8080

> core-js@2.6.9 postinstall /var/www/my/armat/www/node_modules/core-js
> node scripts/postinstall || echo "ignore"

and spent hours to find solution. I was trying to install it on laravel 5.2 that uses older versions of node and npm this helped me

$ npm install -g n
$ n 6.10.2    // selecting version you need in my case 6.10.2
$ npm install -g npm@3.10.10 // same for npm

hope this will help somebody else ^_^

#######UPDATE###########

nvm install 6.10.2
nvm use 6.10.2
npm install -g npm@3.10.10
Mikayel Margaryan
  • 764
  • 1
  • 7
  • 16
  • 1
    this was the same issue for me. used nvm to downgrade from v12 to v10. – Matt Korostoff Jun 24 '21 at 19:47
  • 1
    this was the same issue for me. I was using v10. I downgraded it to v6 and it was working. It is related to the file it tries to download from node-sass, which for v10 was "https://github.com/sass/node-sass/releases/download/v3.13.1/linux-x64-64_binding.node", which does not exist ( the files are named linux-x64-{11,14,42,43,44,45,46,47,48,51}_binding.node, but not 64 (or in your case, 72). However, downgrading from v10 to v6 fixed the problem (downgrading to v8 only changed the 64 to 57, which is still not enough). – Catalin Stan Feb 26 '23 at 10:48
2

only delete

package-lock.json

file

and do npm install again

Ahmed El Damasy
  • 671
  • 6
  • 13
1

I also received the same error

"npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! node-sass@3.13.1 postinstall: node scripts/build.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the node-sass@3.13.1 postinstall script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above."

Solution:

I increased node-sass and gulp-sass versions to latest in package.json file, then issue got fixed.

Mukyuu
  • 6,436
  • 8
  • 40
  • 59
1

If you scroll further up in the error output and you see something like:

gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2

You can fix it on windows with the following steps:

  1. delete node_modules folder
  2. run npm install --global windows-build-toolsin powershell as admin
  3. reinstalling node modules or node-sass with npm install
0

For me, problem was with the Linux directory permissions. Even with sudo and root user I couldn't make it work.

The solution to me was to change project directory owner as follows:

sudo chown my_user:my_user -R /path/to/project 
hljubic
  • 89
  • 1
  • 3
0

Do the following commands respectively:

rm -rf package-lock.json

npm install node-sass@latest
S. Hesam
  • 5,266
  • 3
  • 37
  • 59
0

For Ubuntu

  1. Delete the package-lock.json file

  2. sudo npm install gulp-sass --save-dev

  3. sudo npm install node-sass@latest

0

If you use Visual Studio run following command:

npm cache clean --force
 npm config set msvs_version 2019 --global

where 2019 is the version of Visual Studio

SharpCoder
  • 18,279
  • 43
  • 153
  • 249
0

If you are using OpenBSD, that's because you need g++. Install it using

pkg_add g++

But, it gets installed as ec++, on /usr/local/bin, so you can copy, rename, or create a symlink to it using:

ln -s /usr/local/bin/ec++ /usr/local/bin/g++

Do the npm install again and it should work

0

None of the above worked for me. For different Node versions, different node-saas versions work. My Node version is 10 and I installed node-sass@4.9 successfully. Basically below information helped me. Visiting the site and choosing the correct version of node-saas as per the Node version will help a lot.

https://www.npmjs.com/package/node-sass

Warning: LibSass and Node Sass are deprecated. While they will continue to receive maintenance releases indefinitely, there are no plans to add additional features or compatibility with any new CSS or Sass features. Projects that still use it should move onto Dart Sass.

Node 11 4.10+, <5.0 67

Node 10 4.9+, <6.0 64