概述:
在需要代理才能上网的环境下,需要给npm设置代理才能完成安装 npm install
代理设置:
直接使用npm install会报错,如下:
npm ERR! node v6.7.0 npm ERR! npm v3.10.3 npm ERR! code ETIMEDOUT npm ERR! errno ETIMEDOUT npm ERR! syscall connect npm ERR! network connect ETIMEDOUT 114.55.80.225:443 npm ERR! network This is most likely not a problem with npm itself npm ERR! network and is related to network connectivity. npm ERR! network In most cases you are behind a proxy or have bad network settin gs. npm ERR! network npm ERR! network If you are behind a proxy, please make sure that the npm ERR! network 'proxy' config is set properly. See: 'npm help config'
然后可以尝试输入npm help config,会跳出一个本地页面:
然后输入npm config get userconfig会得到用户配置路径:
C:Users FW2302.npmrc
打开可以看到:
registry=https://registry.npm.taobao.org/
然后配置代理:
npm config set proxy http://用户:密码@代理地址:8080
npm config set https-proxy http://用户:密码@代理地址:8080
需要验证的就如上 用户:密码 @ 代理地址:端口,不需要验证就直接 代理地址:端口
然后就可以使用npm install了,(^o^)/