码迷,mamicode.com
首页 > 其他好文 > 详细

Using NpUsing Npm Behindm Behind a Corporate Proxy

时间:2014-12-16 13:40:44      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:http   ar   io   sp   for   on   bs   ad   ef   

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.
npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://proxy.company.com:8080
If you need to specify credentials, they can be passed in the url using the following syntax.
http://user_name:password@proxy.company.com: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 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 karma
To 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

标签:http   ar   io   sp   for   on   bs   ad   ef   

原文地址:http://my.oschina.net/sunpr/blog/356626

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!