Can you configure NO_PROXY in NPM?

When using a private npm repository, I need the ability to send some requests through a proxy server and others to the server.

Typically, setting the environment variables HTTP_PROXY, HTTPS_PROXY, and NO_PROXY allows this.

I understand that npm does not have a command line option for no_proxy, but I could not get npm to respect the NO_PROXY environment variable: after setting the environment variables above, npm sets the time when loading external libraries (which require loading through a corporate proxy)

The file My ~ / .npmrc has the following:

registry = http: // [internal_npm_registry]

email = [email]

I am running npm version 3.10.10. Has anyone had the same need and resolved this?

+5
source share
2 answers

I had the same problem: we have a private Nexus npm repository where we host some custom modules, and we need npm not to use a proxy when requesting these packages.

The only reliable solution I found for Windows was to specify the environment variables that you specified and actually delete all proxy values ​​from npm (set proxy , https-proxy and https_proxy all to null in the .npmrc file).

So, for example, the .npmrc file in the root of the project looks like this:

 strict-ssl=false ca=null registry=http://my-nexus-repo.com/repository/npm-packages/ my-custom-registry-on-nexus:registry=http://my-nexus-repo.com/repository/hosted-npm-packages/ https_proxy=null https-proxy=null proxy=null 

no_proxy above example, the environment variable no_proxy will look something like this:

my-nexus-repo.com,localhost

This allowed us to easily install all npm packages (even complex ones like node-sass that load tarballs outside of npm).

+5
source

With npm 5.3.0 / node 8.4.0 environment NO_PROXY works like a charm!

+2
source

Source: https://habr.com/ru/post/1262594/


All Articles