NPM 安装崩溃并带有'connection refused'



我想用npm来安装一个软件包。但是,每当我尝试安装任何东西时,npm每次都会崩溃。

这是我不断收到的错误:

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   '-g',
1 verbose cli   'npm' ]
2 info using npm@6.2.0
3 info using node@v10.9.0
4 verbose npm-session 06d9b7b22d5c60b9
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData error for npm@latest request to http://registry.npmjs.org/npm failed, reason: connect ECONNREFUSED 127.0.0.1:80
8 timing stage:rollbackFailedOptional Completed in 1ms
9 timing stage:runTopLevelLifecycles Completed in 73386ms
10 verbose type system
11 verbose stack FetchError: request to http://registry.npmjs.org/npm failed, reason: connect ECONNREFUSED 127.0.0.1:80
11 verbose stack     at ClientRequest.req.on.err (C:Program Filesnodejsnode_modulesnpmnode_modulesnode-fetch-npmsrcindex.js:68:14)
11 verbose stack     at ClientRequest.emit (events.js:182:13)
11 verbose stack     at Socket.socketErrorListener (_http_client.js:391:9)
11 verbose stack     at Socket.emit (events.js:182:13)
11 verbose stack     at emitErrorNT (internal/streams/destroy.js:82:8)
11 verbose stack     at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
11 verbose stack     at process._tickCallback (internal/process/next_tick.js:63:19)
12 verbose cwd C:Userstrinchreposgekko
13 verbose Windows_NT 10.0.17134
14 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "-g" "npm"
15 verbose node v10.9.0
16 verbose npm  v6.2.0
17 error code ECONNREFUSED
18 error errno ECONNREFUSED
19 error FetchError: request to http://registry.npmjs.org/npm failed, reason: connect ECONNREFUSED 127.0.0.1:80
19 error     at ClientRequest.req.on.err (C:Program Filesnodejsnode_modulesnpmnode_modulesnode-fetch-npmsrcindex.js:68:14)
19 error     at ClientRequest.emit (events.js:182:13)
19 error     at Socket.socketErrorListener (_http_client.js:391:9)
19 error     at Socket.emit (events.js:182:13)
19 error     at emitErrorNT (internal/streams/destroy.js:82:8)
19 error     at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
19 error     at process._tickCallback (internal/process/next_tick.js:63:19)
19 error  { FetchError: request to http://registry.npmjs.org/npm failed, reason: connect ECONNREFUSED 127.0.0.1:80
19 error     at ClientRequest.req.on.err (C:Program Filesnodejsnode_modulesnpmnode_modulesnode-fetch-npmsrcindex.js:68:14)
19 error     at ClientRequest.emit (events.js:182:13)
19 error     at Socket.socketErrorListener (_http_client.js:391:9)
19 error     at Socket.emit (events.js:182:13)
19 error     at emitErrorNT (internal/streams/destroy.js:82:8)
19 error     at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
19 error     at process._tickCallback (internal/process/next_tick.js:63:19)
19 error   message:
19 error    'request to http://registry.npmjs.org/npm failed, reason: connect ECONNREFUSED 127.0.0.1:80',
19 error   type: 'system',
19 error   errno: 'ECONNREFUSED',
19 error   code: 'ECONNREFUSED',
19 error   stack:
19 error    'FetchError: request to http://registry.npmjs.org/npm failed, reason: connect ECONNREFUSED 127.0.0.1:80n    at ClientRequest.req.on.err (C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\index.js:68:14)n    at ClientRequest.emit (events.js:182:13)n    at Socket.socketErrorListener (_http_client.js:391:9)n    at Socket.emit (events.js:182:13)n    at emitErrorNT (internal/streams/destroy.js:82:8)n    at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)n    at process._tickCallback (internal/process/next_tick.js:63:19)' }
20 error If you are behind a proxy, please make sure that the
20 error 'proxy' config is set properly.  See: 'npm help config'
21 verbose exit [ 1, true ]

我的设置:我不在代理后面,我的npm配置列表如下所示:

; cli configs
metrics-registry = "http://registry.npmjs.org/"
scope = "@xtrinch"
user-agent = "npm/6.2.0 node/v10.9.0 win32 x64"
; userconfig C:Userstrinch.npmrc
msvs_version = "2017"
registry = "http://registry.npmjs.org/"
; builtin config undefined
prefix = "C:\Users\trinch\AppData\Roaming\npm"
; node bin location = C:Program Filesnodejsnode.exe
; cwd = C:Userstrinchreposgekko
; HOME = C:Userstrinch
; "npm config ls -l" to show all defaults.

软件包版本:

PS C:Userstrinch> node -v
v10.9.0
PS C:Userstrinch> npm -v
6.2.0

你知道我能做些什么吗?到目前为止,我不知道如何解决这个问题。期待我在这个问题上得到任何帮助!

如果您确实需要更多信息,请告诉我!

原来我不小心将http_proxyhttps_proxy和代理用户环境变量设置为解析为本地主机的http://@trinch。删除它们起到了作用。

最新更新