是nodejs的新手,当我尝试npm安装新软件包时,它显示以下错误: 谁能帮助我解决此错误。如果这是较早的响应,则有助于进一步进行。
Nodejs版本 11.2.0
npm版本 6.4.1 .npmrc文件包含以下信息: 注册表= https://registry.npmjs.org 我尝试同时使用https和http,如果我添加自己的代理也存在问题 我做了以下所有这些工作,但是没有运气。
proxy = http://:@proxyhost: https-proxy = http://:@proxyhost:
npm config set strict-ssl false npm config设置注册表“ http://registry.npmjs.org/” npm install
npm ERR! code ECONNREFUSED
npm ERR! errno ECONNREFUSED
npm ERR! FetchError: request to https://registry.npmjs.org/lodash failed, reason: connect ECONNREFUSED 104.16.22.35:443
npm ERR!at ClientRequest.req.on.err (C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\index.js:68:14)
npm ERR!at ClientRequest.emit (events.js:182:13)
npm ERR!at TLSSocket.socketErrorListener (_http_client.js:399:9)
npm ERR!at TLSSocket.emit (events.js:182:13)
npm ERR!at emitErrorNT (internal/streams/destroy.js:82:8)
npm ERR!at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
npm ERR!at process.internalTickCallback (internal/process/next_tick.js:72:19)
npm ERR! { FetchError: request to https://registry.npmjs.org/lodash failed, reason: connect ECONNREFUSED 104.16.22.35:443
npm ERR!at ClientRequest.req.on.err (C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\index.js:68:14)
npm ERR!at ClientRequest.emit (events.js:182:13)
npm ERR!at TLSSocket.socketErrorListener (_http_client.js:399:9)
npm ERR!at TLSSocket.emit (events.js:182:13)
npm ERR!at emitErrorNT (internal/streams/destroy.js:82:8)
npm ERR!at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
npm ERR!at process.internalTickCallback (internal/process/next_tick.js:72:19)
npm ERR!message:
npm ERR!'request to https://registry.npmjs.org/lodash failed, reason: connect ECONNREFUSED 104.16.22.35:443',
npm ERR!type: 'system',
npm ERR!errno: 'ECONNREFUSED',
npm ERR!code: 'ECONNREFUSED',
npm ERR!stack: npm ERR!'FetchError: request to https://registry.npmjs.org/lodash failed, reason: connect ECONNREFUSED 104.16.22.35:443\nat ClientRequest.req.on.err (C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-fetch-npm\\src\\index.js:68:14)\nat ClientRequest.emit (events.js:182:13)\nat TLSSocket.socketErrorListener (_http_client.js:399:9)\nat TLSSocket.emit (events.js:182:13)\nat emitErrorNT (internal/streams/destroy.js:82:8)\nat emitErrorAndCloseNT (internal/streams/destroy.js:50:3)\nat process.internalTickCallback (internal/process/next_tick.js:72:19)' }
完整日志
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 'lodash',
1 verbose cli '--save' ]
2 info using npm@6.4.1
3 info using node@v11.2.0
4 verbose config Skipping project config: C:\Users\nagarsat/.npmrc. (matches userconfig)
5 verbose npm-session 825293c298355ec4
6 silly install loadCurrentTree
7 silly install readLocalPackageData
8 silly fetchPackageMetaData a error for lodash@latest request to https://registry.npmjs.org/lodash failed, reason: connect ECONNREFUSED 104.16.22.35:443
9 timing stage:rollbackFailedOptional Completed in 1ms
10 timing stage:runTopLevelLifecycles Completed in 74227ms
11 verbose type system
12 verbose stack Fetcha error: request to https://registry.npmjs.org/lodash failed, reason: connect ECONNREFUSED 104.16.22.35:443
12 verbose stack at ClientRequest.req.on.err (C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\index.js:68:14)
12 verbose stack at ClientRequest.emit (events.js:182:13)
12 verbose stack at TLSSocket.socketa errorListener (_http_client.js:399:9)
12 verbose stack at TLSSocket.emit (events.js:182:13)
12 verbose stack at emita errorNT (internal/streams/destroy.js:82:8)
12 verbose stack at emita errorAndCloseNT (internal/streams/destroy.js:50:3)
12 verbose stack at process.internalTickCallback (internal/process/next_tick.js:72:19)
13 verbose cwd C:\Users\nagarsat
14 verbose Windows_NT 10.0.16299
15 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "lodash" "--save"
16 verbose node v11.2.0
17 verbose npm v6.4.1
18 error code ECONNREFUSED
19 error errno ECONNREFUSED
20 error Fetcha error: request to https://registry.npmjs.org/lodash failed, reason: connect ECONNREFUSED 104.16.22.35:443
20 error at ClientRequest.req.on.err (C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\index.js:68:14)
20 error at ClientRequest.emit (events.js:182:13)
20 error at TLSSocket.socketa errorListener (_http_client.js:399:9)
20 error at TLSSocket.emit (events.js:182:13)
20 error at emita errorNT (internal/streams/destroy.js:82:8)
20 error at emita errorAndCloseNT (internal/streams/destroy.js:50:3)
20 error at process.internalTickCallback (internal/process/next_tick.js:72:19)
20 error { Fetcha error: request to https://registry.npmjs.org/lodash failed, reason: connect ECONNREFUSED 104.16.22.35:443
20 error at ClientRequest.req.on.err (C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\index.js:68:14)
20 error at ClientRequest.emit (events.js:182:13)
20 error at TLSSocket.socketa errorListener (_http_client.js:399:9)
20 error at TLSSocket.emit (events.js:182:13)
20 error at emita errorNT (internal/streams/destroy.js:82:8)
20 error at emita errorAndCloseNT (internal/streams/destroy.js:50:3)
20 error at process.internalTickCallback (internal/process/next_tick.js:72:19)
20 error message:
20 error 'request to https://registry.npmjs.org/lodash failed, reason: connect ECONNREFUSED 104.16.22.35:443',
20 error type: 'system',
20 error errno: 'ECONNREFUSED',
20 error code: 'ECONNREFUSED',
20 error stack:
20 error 'Fetcha error: request to https://registry.npmjs.org/lodash failed, reason: connect ECONNREFUSED 104.16.22.35:443\n 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 TLocket.socketa errorListener (_http_client.js:399:9)\n at TLSSocket.emit (events.js:182:13)\n at emita errorNT (internal/streams/destroy.js:82:8)\n atmita errorAndCloseNT (internal/streams/destroy.js:50:3)\n at process.internalTickCallback (internal/process/next_tick.js:72:19)' }
21 error If you are behind a proxy, please make sure that the
21 error 'proxy' config is set properly. See: 'npm help config'
22 verbose exit [ 1, true ]
答案 0 :(得分:0)
您需要在npm中配置Web代理。
更多信息:https://jjasonclark.com/how-to-setup-node-behind-web-proxy/
如果这行不通,请尝试使用null,例如以下命令:
npm config set proxy null
npm config set https-proxy null
npm config set registry http://registry.npmjs.org/