npm install throwing error in node-sass

Viewed 66796
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
  • 11 Answers

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

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

    by using yarn run:

    yarn add node-sass
    

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

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

    Use

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

    it works for me

    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

    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

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

    and update package.json in terminal npm install

    Related