reason: certificate has expired,npm原淘宝镜像证书已过期

nodejs qmt 167℃

reason: certificate has expired,npm原淘宝镜像证书已过期

作为一个前端,node已经成为一个不可或缺的东西。我们经常会使用node在项目中安装一些插件工具之类的包,非常方便。但是由于node服务器在国外,所以有的时候我们安装插件的时候会特别慢,甚至出现安装失败的情况。因此很多小伙伴会选择切换npm镜像,如淘宝镜像、腾讯云镜像。

最近遇到的报错:

request to https://registry.npm.taobao.org/npm failed, reason: certificate has expired 

但是原淘宝镜像registry.npm.taobao.org在1月22日的时候正式到期

20240203-v1

所以最近会有很多使用原淘宝镜像安装node包的时候会报错。其实不用担心,你只需要将npm源切换到最新地址registry.npmmirror.com就正常了

永久切换

npm config set registry https://registry.npmmirror.com

临时切换

npm install xxx --registry=https://registry.npmmirror.com

关闭SSl

当然如果你不想切换也是有解决办法的,直接关闭https的ssl验证即可

npm config set strict-ssl false

但是不建议这么做,因为关闭了ssl验证,可能会有一些风险存在。

切换到官方源

如果你想切回官方的npm源,可以直接执行命令

npm config set registry https://registry.npmjs.org/

转载请注明:QMT|Ptrade量化交易 » reason: certificate has expired,npm原淘宝镜像证书已过期

喜欢 (0)