15
node-sass@2.1.1 install /home/user/Documents/project/node_modules/node-sass
> node scripts/install.js

WARN invalid config loglevel="notice"
Can not download file from https://raw.githubusercontent.com/sass/node-sass-binaries/v2.1.1/linux-x64-node-8.2/binding.node

> node-sass@2.1.1 postinstall /home/user/Documents/project/node_modules/node-sass
> node scripts/build.js

module.js:487
    throw err;
    ^

Error: Cannot find module '/home/user/Documents/project/node_modules/node-sass/node_modules/pangyp/bin/node-gyp'
    at Function.Module._resolveFilename (module.js:485:15)
    at Function.Module._load (module.js:437:25)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:158:16)
    at bootstrap_node.js:575:3
Build failed
added 2186 packages in 42.166s

I tried so far:

  • npm rebuild
  • npm rebuild node-sass
  • npm uninstall -g node-sass
  • rm -rf node_module
  • locks
    • 6,537
    • 32
    • 39
    Jahanzaib Seyal
    • 307
    • 1
    • 3
    • 10
    • It seems you need to have `node-gyp` installed. `npm install -g node-gyp` – Mekicha Aug 09 '17 at 11:22
    • 1
      `node-sass@2.1.1` is severely outdated (I tried installing it and was able to reproduce the error); you can try editing `package.json` to use the most recent version instead. (remove `@2.1.1)` –  Aug 09 '17 at 11:25
    • TLDR: replace node-sass with sass. Also not to be "that guy" but there are a lot of wildly incorrect or just strange answers here. Don't bother with python or ruby or node-gyp, just replace it with the pure JS sass - it's identical but takes about 1% of the time to install and won't cause headaches in different envs. – Matt Fletcher Feb 08 '23 at 11:06

    11 Answers11

    22
    1. Remove 'node-sass' dependency from your package.json
    2. run npm install
    3. run npm i sass
    4. run npm start

    You're ready to go! :)

    Usama Muhammad
    • 321
    • 2
    • 4
    12

    You need to do next steps and it should work:

    rm -rf node_modules package-lock.json 
    npm install --saveDev node-sass@4.5.3 
    npm install
    

    Voila :)

    olllejik
    • 1,404
    • 1
    • 10
    • 13
    • 1
      what is the significance of specific version 4.5.3? How to determine this version for my environment? My package.json is tryign to install ^4.11.0 node-sass – dejjub-AIS Dec 01 '19 at 13:25
    4

    by using yarn run:

    yarn add node-sass
    
    Buddy
    • 10,874
    • 5
    • 41
    • 58
    iaMartisan
    • 49
    • 2
    4

    node-sass has minimum dependency according to the version of node installed in your system. You can find out the minimum version required here

    4

    Removed package-lock.json, installed Python 2.7, added an env variable for python path. Ran npm install. Voila !

    Sagar Khatri
    • 575
    • 3
    • 16
    3

    Use

    • Node : v14.16.0
    • node-sass: ^4.14.1

    it works for me

    3

    This question is old, but if you arrive here in 2022 or later, then this info may be useful:

    node-sass is deprecated. Now you should use sass.

    That's why the answer given by Usama Muhammad works. Hope this helps.

    Sources:

    Tyler2P
    • 2,324
    • 26
    • 22
    • 31
    damandak
    • 41
    • 5
    2
    1. Delete package-lock.json
    2. Remove 'node-sass' dependency from your package.json
    3. run npm install
    4. run npm gulp-sass --save-dev
    5. run npm i -d sass
    6. run npm start
    1

    The minimum version with Node 8 support is 4.5.3. Offhand, I don't think 2.x will support anything above Node 0.12, which is EOL.

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

    I have found I get node-sass errors when trying to install over a corporate proxy. The first solution is to ensure your .npmrc file has proxy allowance.

    .npmrc

    # Try removing reference to registry, as sometimes your local corporate registry of node_modules may not include node-sass
    # // registry=https://....
    
    # note if using special characters in pass, encode them: eg: h@ppy = h%40ppy
    strict-ssl=false
    proxy=http://<username>:<pass>@proxyhost:<port>
    https-proxy=http://<uname>:<pass>@proxyhost:<port>
    

    NODE_TLS_REJECT_UNAUTHORIZED = 0

    Then in command line before running any install

    set NODE_TLS_REJECT_UNAUTHORIZED = 0
    

    Zip node-binding files from node-sass github site in order to download them over corporate network.

    Example: https://github.com/inspiraller/node-sass-bindings

    Steve Tomlin
    • 3,391
    • 3
    • 31
    • 63
    0

    Add manually in package.json : "node-sass": "4.13.0"

    and update package.json in terminal npm install

    Anis GH
    • 11