解决CERT_HAS_EXPIRED报错:request to https://registry.npm.taobao.org/xxx failed, reason: certificate


问题复现

有个四五年前的 Vue 2 开发环境,最近需要重新拿来写页面。

之前用淘宝npm源做加速,初始化开发环境时会执行:

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

npm config get registry
# 显示源的地址
# https://registry.npm.taobao.org/

npm源
现在再安装其他模块,会报错CERT_HAS_EXPIRED,更详细点的信息是 “npm ERR! request to https://registry.npm.taobao.org/xxx failed, reason: certificate has expired” ,xxx是模块名字。就像这样

npm ERR! code CERT_HAS_EXPIRED
npm ERR! errno CERT_HAS_EXPIRED
npm ERR! request to https://registry.npm.taobao.org/pyright failed, reason: certificate has expired

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2024-xx-xxTxx_xx_xx_xxxZ-debug-0.log

报错

报错原因

npm.taobao.org 这个域名早在2022年就正式下线了,新域名是 npmmirror.com 。详情可以看官方公告:https://developer.aliyun.com/mirror/NPM

解决方案

改新域名

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

禁止ssl检查

不推荐使用这种方法

npm config set strict-ssl false
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值