noproxy setting with more than one hostname?

help-wanted
cli
triaged
priority:medium
good-first-patch

(KwS) #1

Hi all!

I am trying to run npm as build tool of an angular application. Having to work behind a corporate firewall complicates things quite much…

After updating npm (currently 6.7.0) I found a way to set a no-proxy host with --noproxy like:

npm install --noproxy=internalnexushost --registry=http://internalnexushost/foo/bar/

This works fine, however - since having sass as dependency - I have to add also --sass-binary-site=… like:

npm install --noproxy=internalnexushost --registry=http://internalnexushost/foo/bar/ --sass-binary-site=internalartifactory

This fails because the host of sass-binary-site is not excluded from beeing proxied.

I tried:

npm install --noproxy=internalnexushost,internalartifactory
npm install --noproxy=[internalnexushost internalartifactory]

however this did make the complete noproxy setup failing.

How to set more than one non-proxy host? What am I doing wrong?

Regards
Kristian


(Kat Marchán) #2

This might be a bug in make-fetch-happen. I’m wondering if anyone would like to take a look.


(Lars Willighagen) #3

Installing with .npmrc:

noproxy=foo,registry.npmjs.org
proxy=https://example.com

seems to work fine. As CLI args they fail though.


(Lars Willighagen) #4

This code handles possible arrays:

This causes the option to not be split at commas (which it is if it’s in a config file), but it is put in an array. Workaround:

npm install --noproxy=foo --noproxy=bar

(KwS) #5

Thanks for the quick reply to my initial post.

I tried the workaround with --noproxy=… --noproxy=… , unfortunately it seems to be useless for my usecase, since it does not seem to recognized when the parameter ‘sass-binary-site’ is used during the install process:

[INFO] > node-sass@4.10.0 install C:\path-to-my-project-root\node_modules\node-sass
[INFO] > node scripts/install.js
[INFO]
[INFO] Downloading binary from https://myinternalartifactory/path/to/sass/node-sass/releases/tag/v4.10.0/win32-x64-64_binding.node
[ERROR] Cannot download "https://myinternalartifactory/path/to/sass/node-sass/releases/tag/v4.10.0/win32-x64-64_binding.node":
[ERROR]
[ERROR] tunneling socket could not be established, statusCode=407
[ERROR]
[ERROR] Hint: If github.com is not accessible in your location
[ERROR]       try setting a proxy via HTTP_PROXY, e.g.
[ERROR]
[ERROR]       export HTTP_PROXY=http://example.com:1234
[ERROR]
[ERROR] or configure npm proxy via
[ERROR]
[ERROR]       npm config set proxy http://example.com:8080
[INFO]

The only thing that prevents this error seems to disable the env variables for proxy (http_proxy, https_proxy).
Also, the env var ‘no_proxy’ doesn’ t seem to come in for rescue…

Any other ideas how to get the url provided via ‘sass-binary-site’ to be excluded from proxying? Disabling the global env vars http_proxy, https_proxy is quite a harsh ‘workaround’.

Thanks
Kristian


(Lars Willighagen) #6

node-sass should support NO_PROXY, but I don’t think npm is actually setting that variable, so I don’t know how that would work at all.