问题复现
有个四五年前的 Vue 2 开发环境,最近需要重新拿来写页面。
之前用淘宝npm源做加速,初始化开发环境时会执行:
npm config set registry https://registry.npm.taobao.org/
npm config get registry
# 显示源的地址
# https://registry.npm.taobao.org/
现在再安装其他模块,会报错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 expirednpm 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