我有时候会对一些科学的设置进行改动,然后会发现自家的 Git, npm,Yarn 运行会报类似如下这些错误:
有时候确实是网络差,但大部分时候都是因为我们使用的代理设置修改了,而这些应用却没改。
下面我们来看看如何对 Git, npm,Yarn 进行代理设置。
注意哦,下面的的端口只是举例,大家需要改为自家的端口。
git config --global https.proxy http://127.0.0.1:1087 git config --global http.proxy http://127.0.0.1:1087
上述命令是走 HTTP 代理。
如果你用Shadowsocks,那么还可以试一下走 socks5 代理,命令如下:
git config --global http.proxy 'socks5://127.0.0.1:1087' git config --global https.proxy 'socks5://127.0.0.1:1087'
使用 socks5 的话,速度也会有所提升。
git config --global --get http.proxy git config --global --get https.proxy
如果没有设置代理,上述命令将什么也不会打印。
git config --global --unset http.proxy git config --global --unset https.proxy
yarn config set https-proxy http://127.0.0.1:1087 yarn config set proxy http://127.0.0.1:1087
yarn config list
yarn config delete proxy yarn config delete https-proxy
npm config set proxy http://127.0.0.1:1087 npm config set https-proxy http://127.0.0.1:1087
npm config list
npm config delete proxy npm config delete https-proxy
ok,其实还是蛮简单的,它们各自的文档也有对应说明,这里只是做个汇总,有任何问题欢迎在评论中提出。