npm切换镜像源
最近使用npm淘宝镜像源安装依赖的时候或多或少应该会遇到一个报错 证书已过期 报错其实说的很明确,就是淘宝镜像域名证书已过期
具体报错内容👇
npm ERR! code CERT_HAS_EXPIRED
npm ERR! errno CERT_HAS_EXPIRED
npm ERR! request to https://registry.npm.taobao.org/yarn failed, reason: certificate has expired
虽然证书过期,但是域名一般不会变,试着访问淘宝镜像,会发现自动被中转了,新域名
https://registry.npmmirror.com/
至此,只需将之前的域名替换即可。
- Windows+R 输入
cmd
,打开命令提示符窗口。 - 查看镜像源
npm config get registry
- 清楚npm缓存
npm cache clean --force
- 切换为淘宝镜像(新版)
npm config set registry https://registry.npmmirror.com/
Tip 官方镜像地址🚀
npm config set registry https://registry.npmjs.org/
npm 旧版淘宝镜像源地址
https://registry.npm.taobao.org/