尝试在节点上安装软件包但出现认证错误

时间:2019-06-25 20:15:29

标签: javascript node.js

基本上,每次我尝试执行npm i(程序包)时,都会得到错误的url失败,原因:证书链中的自签名证书。我的问题是如何解决此问题,以便可以安装软件包。

我尝试了不同的软件包,并检查了给出的网址。

记录以下内容:

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   'express',
1 verbose cli   '--save' ]
2 info using npm@6.9.0
3 info using node@v10.16.0
4 verbose npm-session 5a0209091f1c9b93
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 silly fetchPackageMetaData error for express@latest request to 
https://registry.npmjs.org/express failed, reason: self signed 
certificate in certificate chain
8 timing stage:rollbackFailedOptional Completed in 1ms
9 timing stage:runTopLevelLifecycles Completed in 153ms
10 verbose type system
11 verbose stack FetchError: request to 
https://registry.npmjs.org/express failed, reason: self signed 
certificate in certificate chain
11 verbose stack     at ClientRequest.req.on.err (C:\Program 
Files\nodejs\node_modules\npm\node_modules\node-fetch- 
npm\src\index.js:68:14)
11 verbose stack     at ClientRequest.emit (events.js:198:13)
11 verbose stack     at TLSSocket.socketErrorListener 
(_http_client.js:392:9)
11 verbose stack     at TLSSocket.emit (events.js:198:13)
11 verbose stack     at emitErrorNT (internal/streams/destroy.js:91:8)
11 verbose stack     at emitErrorAndCloseNT 
(internal/streams/destroy.js:59:3)
11 verbose stack     at process._tickCallback 
(internal/process/next_tick.js:63:19)
12 verbose cwd C:\Users\bsoong\Desktop\MapEvent
13 verbose Windows_NT 10.0.16299
14 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program 
Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "express" "- 
-save"
15 verbose node v10.16.0
16 verbose npm  v6.9.0

17个错误代码SELF_SIGNED_CERT_IN_CHAIN 18错误errno SELF_SIGNED_CERT_IN_CHAIN 对https://registry.npmjs.org/express的19个错误请求失败,原因:证书链中的自签名证书 20详细出口[1,true]

2 个答案:

答案 0 :(得分:0)

通过以下方式升级npm:

let color1: UIColor = .random let color2: UIColor = .random let color3: UIColor = .random let color4: UIColor = .random let color5: UIColor = .random

-或-

告诉npm通过以下方式使用已知的注册服务商:

npm install npm -g --ca=""

答案 1 :(得分:0)

重新安装nodejs。然后npm config set ca ""