node.js - 呃!网络。无法安装最新版本的 npm、yeoman、bower 和 grunt

标签 node.js gruntjs npm yeoman bower

我在安装 yeoman、bower、grunt 和最新的 npm 版本时遇到问题。

我的电脑上安装了最新版本的 NodeJS (0.12.2)。 我有 npm 版本 2.7.4,但是当我在 nodejs 文件夹中启动 git bash 并键入“npm install npm”或“npm install npm@latest”时,它会给出一条错误消息:

error Windows_NT 6.1.7601
error argv "c:\\Program Files\\nodejs\\node.exe" "c:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "npm@latest"
error node v0.12.2
error npm  v2.7.4
error code ETIMEDOUT
error errno ETIMEDOUT
error syscall connect
error network connect ETIMEDOUT
error network This is most likely not a problem with npm itself
error network and is related to network connectivity.
error network In most cases you are behind a proxy or have bad network settings.
error network
error network If you are behind a proxy, please make sure that the
error network 'proxy' config is set properly.  See: 'npm help config'
verbose exit [ 1, true ]

以及完整的调试日志:

0 info it worked if it ends with ok
1 verbose cli [ 'c:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'c:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install',
1 verbose cli   'npm@latest' ]
2 info using npm@2.7.4
3 info using node@v0.12.2
4 warn package.json nodejs@0.12.2 No description
5 warn package.json nodejs@0.12.2 No repository field.
6 warn package.json nodejs@0.12.2 No README data
7 silly cache add args [ 'npm@latest', null ]
8 verbose cache add spec npm@latest
9 silly cache add parsed spec { raw: 'npm@latest',
9 silly cache add   scope: null,
9 silly cache add   name: 'npm',
9 silly cache add   rawSpec: 'latest',
9 silly cache add   spec: 'latest',
9 silly cache add   type: 'tag' }
10 verbose addNamed npm@latest
11 silly addNamed semver.valid null
12 silly addNamed semver.validRange null
13 info addNameTag [ 'npm', 'latest' ]
14 silly mapToRegistry name npm
15 silly mapToRegistry using default registry
16 silly mapToRegistry registry https://registry.npmjs.org/
17 silly mapToRegistry uri https://registry.npmjs.org/npm
18 verbose addNameTag registry:https://registry.npmjs.org/npm not in flight; fetching
19 verbose request uri https://registry.npmjs.org/npm
20 verbose request no auth needed
21 info attempt registry request try #1 at 09:30:04
22 verbose request id 6fa6dc64e92e52cc
23 http request GET https://registry.npmjs.org/npm
24 info retry will retry, error on last attempt: Error: connect ETIMEDOUT
25 info attempt registry request try #2 at 09:30:35
26 http request GET https://registry.npmjs.org/npm
27 info retry will retry, error on last attempt: Error: connect ETIMEDOUT
28 info attempt registry request try #3 at 09:31:56
29 http request GET https://registry.npmjs.org/npm
30 verbose stack Error: connect ETIMEDOUT
30 verbose stack     at exports._errnoException (util.js:746:11)
30 verbose stack     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1000:19)
31 verbose cwd c:\Program Files\nodejs

我读过一些有 nodejs 问题的帖子,发现可以设置 http 代理。这是解决方案吗?

最佳答案

我已经解决了我的问题。为了在 Windows 7 上找到我的代理服务器名称,我打开了 Windows 命令行并键入:netsh winhttp show proxy

然后我在 .npmrc 数据中添加了这些行(路径:C:\users\username)

registry=http://registry.npmjs.org/
strict-ssl=false
proxy=http://username:password@proxy.domain.com:8080/
https-proxy=http://username:password@proxy.domain.com:8080

它工作正常:)

关于node.js - 呃!网络。无法安装最新版本的 npm、yeoman、bower 和 grunt,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29937452/

相关文章:

node.js - Dialogflow 系统实体 sys.any 在字母数字文本中的数字前添加空格

node.js - Redis -nodejs 简单程序 -ERROR

javascript - 使用javascript读取多个输入行

node.js - grunt watch 任务阻塞命令行

node.js - 安装 create-react-app my-first-react-app 后 npm start 脚本立即返回错误

node.js - Jade 动态数据

ruby - 从 Font-Awesome-Sass gem 中获取字体,复制到 grunt compass 输出目录中

javascript - Typescript 和 Uglify 任务

node.js - 尽管安装了npm,但Gatsby找不到fs

javascript - 在 npm 包中传递 init 值