node-sass: Failed at the node-sass@4.7.2 postinstall script.

  • NPM version (npm -v): 6.0.1
  • Node version (node -v): v8.11.2
  • Node Process (node -p process.versions):
{ http_parser: '2.8.0',
  node: '8.11.2',
  v8: '6.2.414.54',
  uv: '1.19.1',
  zlib: '1.2.11',
  ares: '1.10.1-DEV',
  modules: '57',
  nghttp2: '1.29.0',
  napi: '3',
  openssl: '1.0.2o',
  icu: '60.1',
  unicode: '10.0',
  cldr: '32.0',
  tz: '2017c' }
  • Node Platform (node -p process.platform): undefined
  • Node architecture (node -p process.arch): x64
  • node-sass version (node -p "require('node-sass').info"): Error: Cannot find module ‘node-sass’
  • npm node-sass versions (npm ls node-sass): npm ERR! missing: node-sass@4.7.2, required by projectx@0.0.1

I’m having some problems. Let me try to take you down the steps I took to get me in this situation. Yesterday, everything was working great! Then I did something… I don’t exactly know what I did, but I updated some file from 4.4.0 to 4.7.0… I think it was either Ionic, Cordova, or NPM related.

After updating I got an error saying that Angular CLI is not compatible with my version of Node. For some reason I decided to follow this tutorial to fix: https://github.com/angular/angular-cli/issues/10527 saying:

  1. Download and save a local copy of the correct version of node-sass binary - win32-x64-64_binding.node. For example download it to the following location: C:\node-sass\win32-x64-64_binding.node
  2. Provide reference to the full path of the node-sass binary file in the sass_binary_path npm configuration parameter (in the ~/.npmrc file): npm config set sass_binary_path <path to node-sass binary> For example, npm config set sass_binary_path C:\node-sass\win32-x64-64_binding.node
  3. Run the npm install command again to install @angular/cli correctly.
  4. Execute ng serve or npm start and your should be past the problem.

So I changed the node-sass path. I was still having some issues and realized that to fix I literally just had to download the latest version of NodeJS, which I ended up doing.

I then did npm install on a project I was working on, which then gave me a lovely error:

Failed at the node-sass@4.7.2 postinstall script.

I tried doing npm rebuild node-sass --force which did nothing, unfortunately.

At this point it must’ve been hour 10 of trying to figure out what the heck was going on, so out a fit of frustration I decided to do a Windows 10 recovery for the previous day. But no, I still have problems.

Here is the error report after doing npm install:

Binary found at C:node-sasswin32-x64-64_binding.node
Testing binary
Binary has a problem: { Error: Cannot find module 'C:node-sasswin32-x64-64_binding.node'

// warnings

gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (C:\xampp\htdocs\project x\projectx\node_modules\node-gyp\lib\configure.js:483:19)
gyp ERR! stack     at PythonFinder.<anonymous> (C:\xampp\htdocs\project x\projectx\node_modules\node-gyp\lib\configure.js:508:16)
gyp ERR! stack     at C:\xampp\htdocs\project x\projectx\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:152:21)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\xampp\\htdocs\\project x\\projectx\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\xampp\htdocs\project x\projectx\node_modules\node-sass
gyp ERR! node -v v8.11.2
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Build failed with error code: 1
npm WARN angularfire2@5.0.0-rc.10 requires a peer of @angular/common@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN angularfire2@5.0.0-rc.10 requires a peer of @angular/core@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN angularfire2@5.0.0-rc.10 requires a peer of @angular/platform-browser@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN angularfire2@5.0.0-rc.10 requires a peer of @angular/platform-browser-dynamic@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN angularfire2@5.0.0-rc.10 requires a peer of firebase@^5.0.3 but none is installed. You must install peer dependencies yourself.
npm WARN angularfire2@5.0.0-rc.10 requires a peer of rxjs@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN geofire@4.1.2 requires a peer of firebase@^2.4.0 || 3.x.x but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (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 ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.9.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.9.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\Simon K\AppData\Roaming\npm-cache\_logs\2018-05-27T21_04_57_478Z-debug.log

What should I do? I’ve been struggling with this for hours! Any help, please?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 19 (7 by maintainers)

Most upvoted comments

You should avoid using sudo with npm, it will break things in weird a wonderful ways. Removing sudo should fix your issue.