proxynpm

How to exclude certain domains from an npm proxy


We use npm behind a company firewall and thus use proxy and https-proxy settings in the npm configuration. This works fine as long as all npm modules are loaded from an external registry. But as a matter of fact we also have internal modules on an internal github. The access to these modules must not use the proxy of course. My question is: Can I specify a list of domains in the npm configuration, for which the proxy should not be used? Something like the no_proxy environment variable in the unix shell?


Solution

  • Assuming your environment looks like this:

    NPM must use local Nexus Registry. Configuration file: .npmrc

    registry = https://your.local.nexus.registry/nexus/content/groups/npm/
    

    You can tell npm to use a proxy by setting the environment variables

    http_proxy=http://your.proxy.host:3128
    https_proxy=http://your.proxy.host:3128
    

    but then npm will also try to reach your (local) Nexus Registry using the proxy.

    You need to have one of the latest npm Versions (npm 2.14.7 works fine) and set an additional environment variable to exclude your Nexus Registry from the proxy:

    no_proxy=your.local.nexus.registry