`apt install npm` 之后出现 UNABLE_TO_VERIFY_LEAF_SIGNATURE

`apt install npm` 之后出现 UNABLE_TO_VERIFY_LEAF_SIGNATURE

我实际上正在尝试安装 gTile,它需要 Bazelisk。

在一个相对干净的系统上:

$ sudo apt install npm
# takes almost 5 minutes, then:
$ npm install -g @bazel/bazelisk
npm ERR! code UNABLE_TO_VERIFY_LEAF_SIGNATURE
npm ERR! errno UNABLE_TO_VERIFY_LEAF_SIGNATURE
npm ERR! request to https://registry.npmjs.org/@bazel%2fbazelisk failed, reason: unable to verify the first certificate

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/celiyah/.npm/_logs/2021-05-17T16_21_40_542Z-debug.log

基于这个答案我也尝试过:

$ npm install ssl-root-cas
npm ERR! code UNABLE_TO_VERIFY_LEAF_SIGNATURE
npm ERR! errno UNABLE_TO_VERIFY_LEAF_SIGNATURE
npm ERR! request to https://registry.npmjs.org/ssl-root-cas failed, reason: unable to verify the first certificate

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/celiyah/.npm/_logs/2021-05-17T16_23_34_826Z-debug.log

看起来npmUbuntu 上的安装已经损坏了?

$ npm --version
6.14.8

有人遇到过这个错误吗?如何修复它(不禁用安全性)?

就此而言,请不要提及关闭 SSL。这是一台安全的机器,我希望保持这种状态。:-)

答案1

重新启动后错误消失;sudo apt install npm重新启动计算机后。

相关内容