Is this possible to install node-sass offline proxy

I had a similar problem, while trying to install node-sass behind a corporate proxy.

What you can try is:

  1. Download it locally from here:https://github.com/sass/node-sass/releases (choose the right one depending on your OS)
  2. Use the binary configuration parameter –sass-binary-path. to install it.

    npm install --sass-binary-path="C:\src\v4.7.2\win32-x64-57_binding.node"


How-to

  1. Download the binary here: https://github.com/sass/node-sass/releases It vary depending on your OS and node version.

  2. Set up env variable (see https://github.com/sass/node-sass#binary-configuration-parameters)
    export SASS_BINARY_PATH=<absolute_path_to_file>

Replace <absolute_path_to_file> by the path to the file you have downloaded. The path should be absolute, and in linux format (if you use git bash, with cmd use Windows format). To get the absolute path, you can go to the directory, open a git bash console and do pwd, append the filename, and you should have something like /c/Users/you/SOFTWARE/win32-x64-64_binding.node.

  1. Install (locally)
    npm i node-sass --save

  2. You need to export the variable once for each opened terminal using node-sass. Meaning you should add the export line to your npm start. (so you gotta keep the file you downloaded somewhere safe).

For example you can do "start:dev": "set SASS_BINARY_PATH=%cd%\\win32-x64-64_binding.node && npm start". In this case, the sass binary is inside my project, making it easier for new collaborators. We are using set instead of export because Jetbrain IDE use by default cmd (Windows terminal).


Miscellaneous

If you get an error message like:

Testing binary
Binary has a problem: Error: The module '\\?\C:\Users\myself\SOFTWARE\win32-x64-72_binding.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 72. This version of Node.js requires
NODE_MODULE_VERSION 64. Please try re-compiling or re-installing

It means it have found your binary, but you took the wrong one for your current node version. Dowload the correct version, and do theses above step again.

when using npm start if you have (used on a react-script project):

./src/product-card-list/product-card-list.component.module.scss (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-6-1!./node_modules/postcss-loader/src??postcss!./node_modules/sass-loader/lib/loader.js??ref--6-oneOf-6-3!./src/product-card-list/product-card-list.component.module.scss)
Error: ENOENT: no such file or directory, scandir 'C:\Users\myself\PROJECTS\advisor_spa\node_modules\node-sass\vendor'

You failed step 4. Export SASS_BINARY_PATH again and it should work.


If you use Webstorm, you can make run configuration for npm start and add full path SASS_BINARY_PATH=C:\Users\myself\SOFTWARE\win32-x64-64_binding.node environment variable (for Windows).


If you use Visual Code on Windows, you can add a system env variable, at the same level as PATH (not inside PATH).