11
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,457
    • 31
    • 38
    Jahanzaib Seyal
    • 168
    • 1
    • 2
    • 9
    • 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)` – ChrisG Aug 09 '17 at 11:25

    10 Answers10

    10

    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,324
    • 9
    • 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
    3

    by using yarn run:

    yarn add node-sass
    
    Buddy
    • 10,627
    • 5
    • 40
    • 57
    iaMartisan
    • 39
    • 2
    3

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

    Sagar Khatri
    • 545
    • 3
    • 15
    2

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

    2

    Use

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

    it works for me

    2
    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! :)

    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
    • 3,816
    • 1
    • 26
    • 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
    • 2,480
    • 3
    • 22
    • 39
    0

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

    and update package.json in terminal npm install

    0
    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