NPM Git Yarn 如何设置代理

NPM Git Yarn 如何设置代理

  • 前言
  • 设置方法
    • NPM
      • 设置方法
      • 查看
      • 取消方法
    • Yarn
      • 设置方法
      • 查看
      • 取消方法
    • Git
      • 设置方法
      • 查看
      • 取消方法
      • 代理某一个域名

前言

由于有时候网络的原因,会导致 npmgityarn 下载遇到各种各样的问题。而且我们正好会使用科学上网方法。那么我们就可以为 npmgityarn 设置代理。让它们通过代理的方式的得到更优的下载网络,从而解决疑难杂症。

设置方法


NPM

设置方法

# http http://127.0.0.1:8081
npm config set proxy http://proxy_host:port  

# https
npm config set https-proxy http://proxy_host:port

查看

npm config list

取消方法

npm config delete proxy
npm config delete https-proxy

Yarn

设置方法

# http
yarn config set proxy http://proxy_host:port  

# https
yarn config set https-proxy http://proxy_host:port  

查看

yarn config list

取消方法

yarn config delete proxy
yarn config delete https-proxy

Git

设置方法

http 代理

# https
git config --global https.proxy http://proxy_host:port  

# http
git config --global http.proxy http://proxy_host:port

socks 代理

git config --global http.proxy 'socks5://proxy_host:port'
git config --global https.proxy 'socks5://proxy_host:port'

查看

git config --global  --get http.proxy
git config --global  --get https.proxy

取消方法

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

代理某一个域名

git config --global http.https://github.com.proxy 'socks5://proxy_host:port'
git config --global https.https://github.com.proxy 'socks5://proxy_host:port'

你可能感兴趣的:(其他,git,npm,yarn)