On a recent assignment, I needed to install NPM behind a corporate proxy. I had already set the environment variables Http_proxy and Https_proxy. Other command line utilities, like Ruby Gems, recognized these environment variables. NPM did not.
After some googling, I found the following-to-configure the proxy for NPM.
NPM Config set proxy http://proxy.company.com:8080npm config set https-proxy http://proxy.company.com:8080
If you need to specify credentials, they can is passed in the URL using the following syntax.
Http://user_name:[email protected]:8080
Further exploration of the NPM Config documentation showed that the NPM Config set command sets the proxy configuration in Your. npmrc file. You can also set the proxy configuration as a command line argument or environment variable.
Configuration parameters can specified using-when executing NPM. So the proxy could also is specified as follows.
NPM--https-proxy=http://proxy.company.com:8080-g Install Karma
To pass configurattion parameters to NPM as environment variables, they must is prefixed with npm_config_. The proxy configuration could is set with environment variables as follows.
Export Npm_config_proxy http://proxy.company.com:8080export npm_config_https_proxy http://proxy.company.com:8080
Using npusing Npm behindm Behind a Corporate Proxy