npm设置代理

服务器的机子,只能访问内网,不能访问外网。
npm 安装命令都要有外网访问。难道一个接一个下载依赖包?


答案很简单,用代理,把服务器上的npm,设置代理到可以访问外网的机子上(代理工具:ccproxy、fiddler等),即可解决问题!

npm congif set proxy=http://192.168.1.1:8080

#npm config set proxy http://proxy.company.com:8080
#npm config set https-proxy http://proxy.company.com:8080


搞到以后,删除代理设置:
#npm config delete proxy
#npm config delete https-proxy

其它详细参数:https://npmjs.org/doc/config.html


附:直接给linux设置网络代理:
#export http_proxy http://proxy.company.com:8080
#export https_proxy http://proxy.company.com:8080


经过试验,cnpm比npm好用多了,这两天不知道是不是npm服务器抽风了,用npm install安装插件的时候,速度比蜗牛还要慢,好几次都在安装到一半的时候停下了,经过grunt群里面的两位大神指点后改用cnpm,速度马上就起来了,分分钟搞定~具体的设置方法为:
 npm set registry=http://r.cnpmjs.org/ 

 

posted @ 2014-02-11 14:21  橘子小睿  阅读(1594)  评论(0编辑  收藏  举报