【问题标题】:unable to verify the first certificate when running npm install运行 npm install 时无法验证第一个证书
【发布时间】:2017-02-21 09:27:43
【问题描述】:

我正在查看 Angular2 教程: https://github.com/angular/quickstart/blob/master/README.md

但是,当我按照指南运行 npm install 时,我最初收到与 UNABLE_TO_VERIFY_LEAF_SIGNATURE 相关的错误。 谷歌搜索似乎与 SSL 证书有关,所以我尝试使用以下命令解决这个问题:

npm config set strict-ssl false

然后我重试npm install

这更进一步,但随后出现了与“无法验证第一个证书”相关的新错误:

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

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

typings ERR! If you need help, you may report this error at:
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: fsevents@1.0.14
npm WARN angular-quickstart@1.0.0 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! angular-quickstart@1.0.0 postinstall: `typings install`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the angular-quickstart@1.0.0 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 ERR! Please include the following file with any support request:
npm ERR!     c:\Code\Angular2\Quickstart\npm-debug.log

我是 NodeJS 和 Angular2 开发的新手。有任何想法吗 ? 如果我遗漏了任何细节,请告诉我。

【问题讨论】:

  • 如果你用谷歌搜索 npm EUNAVAILABLE 你会得到很多打字错误。您可以尝试手动安装类型。例如npm install typings -g --msvs-version=2015 对我有用。
  • 附注我还在节点 4.2.3
  • @leetibbett 我尝试了这个建议,然后重新运行了相同的 npm install 命令,但仍然遇到相同的错误
  • 那么手动全局安装类型是成功还是失败?
  • 如果您使用 Web 浏览器下载自动配置脚本并查看它,它应该包含代理名称。从那里您可以使用npm config set proxy=http://&lt;proxy&gt;:&lt;port&gt; 将其配置到 npm 中。您可能还需要配置 git,我认为它类似于 git configure --add http.proxy http://&lt;proxy&gt;:&lt;port&gt;

标签: angularjs node.js ubuntu ssl


【解决方案1】:

您可以尝试在config中将注册表更改为http版本

npm config set registry http://registry.npmjs.org/ --global

【讨论】:

  • 设置后,我看到了同样的问题,因为 npm 正在尝试安装以下内容并再次失败。消息无法连接到“api.typings.org/entries/dt/node/tags****
  • 我尝试使用浏览器访问 api.typings.org/entries/dt/node/tags 并收到此消息:Cannot GET /entries/dt/node/tags/
  • 使用@Rubans 提供的方法。它对我有用。
  • 运行上面的 npm 配置后它工作了。我能够使用“create-react-app”创建一个新应用。
【解决方案2】:

在我的情况下,将 .npmrc 中的 ca 文件添加到公司代理证书是解决方案:

npm config set cafile "path to proxy cert file"

或在 .npmrc 中使用编辑器插入:

cafile=<path to proxy cert file>

.npmrc 文件位于主目录中。

【讨论】:

    【解决方案3】:

    我能够按照此处的说明解决此问题: https://github.com/typings/typings/issues/564

    这个问题最终与我的机器位于某些公司代理后面有关,这似乎与 npm 无法针对代理验证 https 有关。 由于我没有关于正在使用的代理的任何进一步信息,因此无法按照上面的@leetibbett 建议进行配置。 所以我在根目录下创建了 .typingsrc 文件来使用 http 版本:

    {
         "rejectUnauthorized": false,
         "registryURL": "http://api.typings.org/"
    }
    

    【讨论】:

      【解决方案4】:

      我卸载了节点 Js 12 并重新安装了版本 10。这解决了我的问题。我不确定问题是否是版本,但你可以试试。希望对您有所帮助。

      【讨论】:

        猜你喜欢
        • 2017-06-26
        • 2021-10-20
        • 2021-01-02
        • 2020-02-17
        • 2021-03-26
        • 1970-01-01
        • 2018-08-29
        • 2020-03-29
        • 2021-06-15
        相关资源
        最近更新 更多