为 git、npm、yarn 设置代理

本文介绍了如何为 git、npm、yarn 设置代理。

添加代理

git

1
2
git config --global http.proxy 'http://127.0.0.1:10809'
git config --global https.proxy 'http://127.0.0.1:10809'

npm

1
2
3
4
5
6
7
8
# 设置代理
npm config set proxy="http://127.0.0.1:10809"
npm config set https-proxy="http://127.0.0.1:10809"

# 设置镜像源
npm config set registry "https://registry.npmmirror.com/"
npm config set registry "https://registry.npmjs.org/"

yarn

1
2
3
4
5
6
7
# 设置代理
yarn config set proxy "http://127.0.0.1:10809"
yarn config set https-proxy "http://127.0.0.1:10809"

# 设置镜像源
yarn config set registry "https://registry.npmmirror.com/"
yarn config set registry "https://registry.npmjs.org/"

查看代理

git

1
git config --list

npm

1
2
npm config get proxy
npm config get https-proxy

yarn

1
yarn config list

取消代理

git

1
2
git config --global --unset http.proxy
git config --global --unset https.proxy

npm

1
2
npm config delete proxy 
npm config delete https-proxy

yarn

1
2
yarn config delete proxy  
yarn config delete https-proxy

为 git、npm、yarn 设置代理
https://operapeking.github.io/2022/05/24/proxy/
作者
Peking Opera
发布于
2022年5月24日
许可协议