npm 安装 error/issue

npm install error/issue

我已经在.npmrc 文件中设置了代理配置。 执行 npm install 命令会出现如下错误

$ npm install npm ERR! Windows_NT 6.1.7601 npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" npm ERR! node v6.9.4 npm ERR! npm v3.10.10 npm ERR! code ECONNRESET

npm ERR! network tunneling socket could not be established, statusCode=400 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 settings. 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 ERR! Please include the following file with any support request: npm ERR! D:\Pooja\quickstart\npm-debug.log

用户文件夹中的 .npmrc 文件包含以下值

 1. registry=https://registry.npmjs.org/
 2. proxy=http://proxy@domain.com:8080/
 3. http_proxy=http://username:password@proxy@domain.com:8080/

有什么办法可以解决这个问题吗?

您的代理 URL 中是否有“@”符号? @ 符号将用户 ID 和密码与 URL 分开。如果是,您可以尝试使用“%40”来替换它。

此外,它是 https-proxy 而不是 http_proxy。

正确的配置应该是 -

registry=https://registry.npmjs.org/
proxy=http://username:password@proxydomain:8080/
https-proxy=https://username:password@proxydomain:8080/

https://docs.npmjs.com/misc/config#proxy

先下命令 并检查是否设置了代理,npm config get proxy 如果未设置,请从命令提示符

执行以下操作

npm config set proxy http://username:password@proxy address:8080 npm config set https-proxy http://username:password@proxy address:8080

如果密码包含'@'in password, then replace it with '%40'

有国内的朋友可以用淘宝镜像解决这个问题

npm --registry=https://registry.npm.taobao.org 安装