节点js安装npm时出错安装快速代码UNABLE_TO_VERIFY_LEAF_SIGNATURE无法验证第一个证书

Pra*_*shi 5 windows node.js express

我安装了nodejs版本node-v4.5.0-x64.msi

我在Windows中使用 npm install express安装express,但是出现以下错误

npm WARN package.json demo2@1.0.0 No description                                    
npm WARN package.json demo2@1.0.0 No repository field.

npm WARN package.json demo2@1.0.0 No README data
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\
node_modules\\npm\\bin\\npm-cli.js" "install" "express"
npm ERR! node v4.5.0
npm ERR! npm  v2.15.9
npm ERR! code UNABLE_TO_VERIFY_LEAF_SIGNATURE

npm ERR! unable to verify the first certificate
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     D:\user\Node\demo2\npm-debug.log
Run Code Online (Sandbox Code Playgroud)

更新 不仅快递包我无法安装任何包

abd*_*rik 11

您可以使用此命令

npm config set strict-ssl false

它只是禁用了SSL证书.

但接受无效的SSL证书并不是最佳做法.

您可以稍后使用此命令恢复它

npm config set strict-ssl true


whi*_*der 5

我认为可以禁用正确的解决方案,而不是禁用可能绕过公司安全策略的SSL证书检查(这不是一个好主意):

npm config set cafile="/path/to/cert_authority_file_base64.cer"
Run Code Online (Sandbox Code Playgroud)

这样可以解决“无法验证第一个证书”错误,而无需禁用SSL证书检查。

注意:“ cert_authority_file_base64.cer”文件可以在Chrome中使用绿色锁定图标从任何HTTPS访问的网站(组织网络外部)在Chrome中获取,并通过单击绿色按钮从出现的菜单中导航到“详细信息”链接图标。您必须将证书另存为“ base64编码”才能起作用。