常用命令行工具镜像源或代理的配置与使用

npm 镜像

查看当前镜像源

1
npm config get registry

返回 npm 官方源

1
npm config set registry https://registry.npmjs.org/

使用国内镜像源

1
npm config set registry https://registry.npmmirror.com
1
npm config set registry https://npm.aliyun.com
1
npm config set registry http://mirrors.cloud.tencent.com/npm/
1
npm config set registry https://mirrors.huaweicloud.com/repository/npm/

GIT Proxy

查看当前代理

1
git config --global --list

取消代理

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

配置 HTTP 代理

以下代码仅为示例,请根据实际的 Windows 代理地址和端口填写!

如何查看 Windows 代理的地址和端口?
  1. 打开「控制面板」窗口
  2. 选择「网络和 Internet」选项
  3. 选择「Internet 选项」,弹出「Internet 属性」窗口
  4. 切换到「连接」选项卡
  5. 点击「局域网设置 (L)」按钮,弹出「局域网 (LAN) 设置」窗口
  6. 在「代理服务器」中查看「地址 (E)」和「端口 (T)」
1
git config --global http.proxy "http://127.0.0.1:10809"; git config --global https.proxy "http://127.0.0.1:10809"

pip 镜像

查看当前镜像源

1
pip config list

返回 pip 官方源

1
pip config unset global.index-url

使用国内镜像源

1
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
1
pip config set global.index-url https://pypi.mirrors.ustc.edu.cn/simple
1
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple
1
pip config set global.index-url https://mirrors.cloud.tencent.com/pypi/simple
1
pip config set global.index-url https://repo.huaweicloud.com/repository/pypi/simple/
1
pip config set global.index-url https://pypi.douban.com/simple