服务器的机子,只能访问内网,不能访问外网。 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
原文:http://www.cnblogs.com/lirui1992/p/3544309.html