如果使用代理服务器,Node.js就需要设置代理,否则用npm
下载什么都不好使
npm config set proxy http://server:port
npm config set https-proxy http://server:port
例如
npm config set proxy http://127.0.0.1:8080
npm config set https-proxy http://127.0.0.1:8080
如果代理需要认证的话可以这样来设置
npm config set proxy http://username:password@server:port
npm config set https-proxy http://username:pawword@server:port
查看config
配置
npm config list
清除npm的代理
npm config delete proxy
npm config delete https-proxy