至于為什么要使用代理,怎么申請代理咽斧,這里就不說了堪置。
一、解決git速度慢
1张惹、git配置代理
git config --global http.proxy http://127.0.0.1:6152
git config --global https.proxy http://127.0.0.1:6152
2舀锨、git取消代理
git config --global --unset http.proxy
git config --global --unset https.proxy
3、加快git解析速度(配置host)
通過修改hosts文件
sudo vim /etc/hosts
加入
151.101.44.249 github.global.ssl.fastly.Net
這里的ip就是從http://github.global.ssl.fastly.net.ipaddress.com/#ipinfo獲取最快的ip
二宛逗、解決npm被墻(參考npm翻墻坎匿、nrm鏡像切換)
1、npm代理設置
npm config set proxy=http://127.0.0.1:6152
npm config set https_proxy=http://127.0.0.1:6152
2雷激、npm取消代理
npm config delete proxy
npm config delete https_proxy
3替蔬、也可以通過切換國內(nèi)鏡像解決
手工切換國內(nèi)鏡像
npm config set registry=http://r.cnpmjs.org
注意:使用國內(nèi)鏡像的時候就不要使用代理了
4、使用nrm快速切換鏡像
npm install -g nrm
如何切換:
nrm use cnpm
測試鏡像速度
nrm test cnpm