首页 > 代码库 > Using NpUsing Npm Behindm Behind a Corporate Proxy
Using NpUsing Npm Behindm Behind a Corporate Proxy
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 way to configure the proxy for npm.
Configuration parameters can be specified using -- when executing npm. So the proxy could also be specified as follows.
After some googling, I found the following way to configure the proxy for npm.
npm config set proxy http://proxy.company.com:8080 npm config set https-proxy http://proxy.company.com:8080If you need to specify credentials, they can be passed in the url using the following syntax.
http://user_name:password@proxy.company.com:8080Further 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 be specified using -- when executing npm. So the proxy could also be specified as follows.
npm --https-proxy=http://proxy.company.com:8080 -g install karmaTo pass configurattion parameters to npm as environment variables, they must be prefixed with npm_config_. The proxy configuration could be set with environment variables as follows.
export npm_config_proxy http://proxy.company.com:8080 export npm_config_https_proxy http://proxy.company.com:8080
Using NpUsing Npm Behindm Behind a Corporate Proxy
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。