繁体   English   中英

NPM 不安装任何模块:网络套接字挂断

[英]NPM doesn't install any modules: network socket hangs up

Salam(意思是你好):)

我在 ubuntu 12.04 上安装了最新版本的 node.js,我没有使用任何代理,并且我的网络设置已正确配置,并且自上次 NPM 正常工作以来一直完好无损。 但是现在 NPM 挂断了任何模块的安装,并出现以下错误:

nasser@nasser-desktop:~/projects/server v3$ npm install simple-proxy
npm WARN package.json docco@0.6.2 No repository field.
npm http GET https://registry.npmjs.org/simple-proxy
npm http GET https://registry.npmjs.org/simple-proxy
npm http GET https://registry.npmjs.org/simple-proxy
npm ERR! network socket hang up
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! System Linux 3.5.0-17-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "simple-proxy"
npm ERR! cwd /home/nasser/projects/serverV3
npm ERR! node -v v0.10.18
npm ERR! npm -v 1.3.8
npm ERR! code ECONNRESET
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/nasser/projects/serverV3/npm-debug.log
npm ERR! not ok code 0

我有同样的问题。 看来 ISP 的 https 处理存在一些问题。 做:

npm config set registry http://registry.npmjs.org/

为我工作

我遇到了同样的问题。 在此线程中找到了解决方案。 您可以通过执行以下操作来查看npm正在使用的有效代理:

npm config get proxy
npm config get https-proxy

如果你在代理后面,试试这个:

mv ~/.npmrc ~/.npmrc.bak

我的 Windows 机器也有类似的问题,我首先通过执行以下命令检查我的代理是否获得了一些值来修复它。

npm config get proxy

作为回报,我得到了以下内容:

http://usr:pwd@host/:port

因此,如果任何不在代理层下的人首先通过执行以下命令将代理设置为空。

npm config set proxy null

现在如果你执行你的 npm i 它不应该抛出任何网络错误。

我尝试了多种解决方案,但发生在我身上的大多数情况是网络/ssl 和代理问题。网络/ssl 情况非常普遍,有很多解决方案,但我与您分享了我的解决方案。

bash 命令:

npm config set proxy null
npm config set https-proxy null
npm config set http-proxy null

就我而言,我使用的是https://registry.npmjs.org/ url。 NULL 代理后它开始工作。 npm 将默认代理设置为http://my-proxy.com:1080/,因此我们必须更改代理 url 或将其设为 null。 要在 bash 中使用以下命令获取默认代理。

npm config get proxy

如果您使用具有用户名和密码身份验证的代理,请尝试将代理设置为

npm 配置设置代理http://username:encodedpassword@proxyaddress:port

npm 配置集 https-proxy http://username:encodedpassword@proxyaddress:port

运行前只需按照以下步骤操作: npm install -g @angular/cli

  1. npm cache clean (如果抛出错误,您甚至可以忽略)
  2. npm config set strict-ssl false
  3. npm config set proxy http://myusername:mypassword@proxyaddress:port
  4. npm config set https-proxy http://myusername:mypassword@proxyaddress:port

将代理和 http_proxy 字段与您的凭据(如果包含任何特殊字符进行编码)添加到您的 .npmrc 文件中,然后再次运行 npm install。 它应该工作。

例如:

proxy= http://username:passcode@proxyURL:80/ https_proxy= http://username:passcode@proxyURL:80

找到 .npmrc 文件,用记事本打开。 然后删除那里的代理设置

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM