【问题标题】:No longer able to upgrade npm from 6 to 7: "Using stale data" from UNABLE_TO_GET_ISSUER_CERT_LOCALLY不再能够将 npm 从 6 升级到 7:来自 UNABLE_TO_GET_ISSUER_CERT_LOCALLY 的“使用陈旧数据”
【发布时间】:2021-10-12 04:59:55
【问题描述】:

我正在使用 nvm 和最新的稳定 Node (16)

$ nvm ls
->      v16.2.0

npm 最近使用了 vague blog post 来强制实施 TLS 1.1。

根据another blog post npm@latest 应该是npm 7。但是,对我来说:

npm install -g npm@latest
npm WARN npm npm does not support Node.js v16.2.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 6, 8, 9, 10, 11, 12, 13.
npm WARN npm You can find the latest version at https://nodejs.org/
npm WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning UNABLE_TO_GET_ISSUER_CERT_LOCALLY: request to https://registry.npmjs.org/npm failed, reason: unable to get local issuer certificate
npm WARN registry Using stale data from https://registry.npmjs.org/ due to a request error during revalidation.

+ npm@6.13.0
updated 1 package in 9.573s

您可以看到 @latest for me 解析为 npm 6.13.0,此警告的关键部分似乎是:

https://registry.npmjs.org/:其他警告 UNABLE_TO_GET_ISSUER_CERT_LOCALLY:对https://registry.npmjs.org/npm 的请求失败,原因:无法获取本地颁发者证书 由于重新验证期间出现请求错误,npm WARN 注册表使用来自 https://registry.npmjs.org/ 的陈旧数据。

我曾经将我的注册表设置为使用 http,如下所示:

$ npm config get registry
http://registry.npmjs.org/

所以我尝试取消设置,显然它会自动设置为https(这很好):

$ npm config delete registry

$ npm config get registry
https://registry.npmjs.org/

但是,在运行 npm install -g npm@latest 时,我得到了相同的“陈旧数据”和 UNABLE_TO_GET_ISSUER_CERT_LOCALLY 警告。 npm install -g npm 的相同警告。我无法再升级 npm。

我没有使用 VPN 或使用任何代理。我该如何解决这个问题?

【问题讨论】:

    标签: node.js npm registry


    【解决方案1】:

    首先我尝试使用 nvm 重新安装节点,将我升级到 nvm 8,但未能解决问题:

    nvm reinstall-packages 16
    

    经过一番头撞后,我注意到我的~/.npmrc 中有一行:

    ca[]=
    

    出于某种原因,我将 npm 配置为没有用于验证 SSL 的根证书。删除该行解决了我的问题。

    【讨论】:

      猜你喜欢
      • 2018-01-15
      • 2020-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-05
      • 1970-01-01
      • 2020-06-16
      相关资源
      最近更新 更多