前言
Npm配置代理
HTTP代理
<port>
:代理端口号
1 2
| npm config set proxy "http://localhost:<port>" npm config set https-proxy "http://localhost:<port>"
|
有密码的代理
1 2
| npm config set proxy "http://username:password@localhost:<port>" npm confit set https-proxy "http://username:password@localhost:<port>"
|
SOCKS5代理
- npm不直接支持SOCKS5代理
- 但是可以通过一个插件实现代理端口转发,从而实现SOCKS5代理
<port_socks5>
:SOCKS5代理端口
<port>
:转发后的端口
1 2 3 4 5 6 7 8 9
| # 安装插件 npm install -g http-proxy-to-socks
# 端口转发 hpts -s localhost:<port_socks5> -p <port>
# npm代理 npm config set proxy "http://localhost:<port>" npm config set https-proxy "http://localhost:<port>"
|
删除代理
1 2
| npm config delete proxy npm config delete https-proxy
|
完成
参考文献
freesilo Blog