工作中可能需要对有些命令设置代理, 我把最近使用的命令进行了总结,后面遇到其他命令也会持续进行更新。
git设置和取消代理
git设置代理
git config --global http.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
git取消代理
git config --global --unset http.proxy
git config --global --unset https.proxy
npm设置和取消代理
npm设置代理
npm config set proxy http://server:port
npm config set https-proxy http://server:port
如果代理需要认证的话可以这样来设置。
npm config set proxy http://username:password@server:port
npm config set https-proxy http://username:pawword@server:port
npm取消代理
npm config delete proxy
npm config delete https-proxy
如果代理不支持https的话需要修改npm存放package的网站地址。
npm config set registry 'https://registry.npm.taobao.org
也可以通过安装cnpm的方式解决
npm install -g cnpm --registry=https://registry.npm.taobao.org