node.js 运行 npm install 时无法验证第一个证书
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40000952/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
unable to verify the first certificate when running npm install
提问by Rubans
I'm was looking at the Angular2 tutorial on: https://github.com/angular/quickstart/blob/master/README.md
我正在查看 Angular2 教程:https: //github.com/angular/quickstart/blob/master/README.md
However, when I run the npm install as per the guide, i initially got an error related to UNABLE_TO_VERIFY_LEAF_SIGNATURE. Which on googling seemed related to SSL cert so I then attempted to just get around this by using the following command:
但是,当我按照指南运行 npm install 时,我最初遇到了与 UNABLE_TO_VERIFY_LEAF_SIGNATURE 相关的错误。谷歌搜索似乎与 SSL 证书有关,因此我尝试使用以下命令解决此问题:
npm config set strict-ssl false
I then retried npm install
然后我重试 npm install
This got a bit further but then got new errors related to "unable to verify the first certificate ": typings ERR! message Unable to connect to "https://api.typings.org/entries/dt/core-js/tags/0.0.0%2B20160725163759" typings ERR! caused by unable to verify the first certificate
这有点进一步,但随后出现了与“无法验证第一个证书”相关的新错误:打字错误!消息无法连接到“ https://api.typings.org/entries/dt/core-js/tags/0.0.0%2B20160725163759”打字错误!无法验证第一个证书导致
typings ERR! cwd c:\Code\Angular2\Quickstart typings ERR! system Windows_NT 6.1.7601 typings ERR! command "C:\Program Files\nodejs\node.exe" "c:\Code\Angular2\Quickstart\node_modules\typings\dist\bin.js" "install" typings ERR! node -v v6.7.0 typings ERR! typings -v 1.4.0 typings ERR! code EUNAVAILABLE
打字错误!cwd c:\Code\Angular2\Quickstart 打字错误!系统 Windows_NT 6.1.7601 打字错误!命令 "C:\Program Files\nodejs\node.exe" "c:\Code\Angular2\Quickstart\node_modules\typings\dist\bin.js" "install"typings ERR!node -v v6.7.0 打字错误!打字 -v 1.4.0 打字错误!代码不可用
typings ERR! If you need help, you may report this error at: typings ERR! https://github.com/typings/typings/issues
打字错误!如果您需要帮助,您可以在以下位置报告此错误:typings ERR! https://github.com/typings/typings/issues
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]
npm WARN [email protected] No license field.
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install"
npm ERR! node v6.7.0
npm ERR! npm v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! [email protected] postinstall: typings installnpm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script 'typings install'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the angular-quickstart package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! typings install
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs angular-quickstart
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls angular-quickstart
npm ERR! There is likely additional logging output above.
npm WARN 可选跳过失败的可选依赖项 /chokidar/fsevents:npm WARN notsup 与您的操作系统或架构不兼容:[email protected] npm WARN [email protected] 无许可证字段。npm 错误!Windows_NT 6.1.7601 npm 错误!argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "安装" npm ERR!node v6.7.0 npm ERR!npm v3.10.3 npm ERR!代码 ELIFECYCLE npm ERR![email protected] 安装后:typings install错误!退出状态 1 npm ERR!错误!在 [email protected] 安装后脚本 'typings install' 失败。错误!确保您安装了最新版本的 node.js 和 npm。错误!如果这样做,这很可能是 angular-quickstart 包 npm ERR 的问题!不是 npm 本身。错误!告诉作者这在你的系统上失败了:npm ERR!打字安装 npm ERR!您可以通过以下方式获取有关如何为此项目打开问题的信息:npm ERR!npm 错误 angular-quickstart npm ERR!或者,如果这不可用,您可以通过以下方式获取他们的信息:npm ERR!npm 所有者 ls angular-quickstart npm ERR!上面可能有额外的日志输出。
npm ERR! Please include the following file with any support request: npm ERR! c:\Code\Angular2\Quickstart\npm-debug.log
错误!请在任何支持请求中包含以下文件:npm ERR!c:\Code\Angular2\Quickstart\npm-debug.log
I'm new to NodeJS and Angular2 development. Any ideas ? If I have missed out any detail then let me know.
我是 NodeJS 和 Angular2 开发的新手。有任何想法吗 ?如果我遗漏了任何细节,请告诉我。
采纳答案by Rubans
I was able to resolve the issue by using the instructions here: https://github.com/typings/typings/issues/564
我能够通过使用此处的说明解决该问题:https: //github.com/typings/typings/issues/564
The issue is ultimately related to my machine being behind some corporate proxy which seems to be related to npm unable to authenticate https against the proxy. Since I didn't have any further information about the proxy being used so was unable to configure as per @leetibbett suggestion above. So I created .typingsrc file in the root directory to use http version:
该问题最终与我的机器位于某个公司代理后面有关,这似乎与 npm 无法针对代理验证 https 相关。由于我没有关于正在使用的代理的任何进一步信息,因此无法按照上面的@leetibbett 建议进行配置。所以我在根目录中创建了 .typingsrc 文件来使用 http 版本:
{
"rejectUnauthorized": false,
"registryURL": "http://api.typings.org/"
}
回答by Thiago Falcao
You can try change the registry to the http version in config
您可以尝试在配置中将注册表更改为 http 版本
npm config set registry http://registry.npmjs.org/ --global
回答by Paulo Ricardo - IFPE - Campus
I uninstalled the node Js 12 and reinstalled the version 10. That solved my problem. I am not sure if the problem was the version, but you can try. I hope that has helped you.
我卸载了节点 Js 12 并重新安装了版本 10。这解决了我的问题。我不确定是否是版本的问题,但您可以尝试。我希望这对你有帮助。

