registry.npm.taobao.org certificate expired证书已过期解决方案

今天心血来潮,打开Terminal,准备学习一下react。

按照惯例,先初始化一个工程,写一个Hello World,然后完事。

结果,结果,刚执行命令就报错了,各位看看有没有遇到同样的情况:

# npx create-react-app reactDemo
npm ERR! code CERT_HAS_EXPIRED
npm ERR! errno CERT_HAS_EXPIRED
npm ERR! request to https://registry.npm.taobao.org/create-react-app failed, reason: certificate has expired

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/admin/.npm/_logs/2024-02-05T13_30_32_079Z-debug-0.log

registry.npm.taobao.orgcertificateexpired证书已过期解决方案

看了一下,原来是淘宝镜像原地址的证书2024年1月22日已过期,镜像仓库换地址了

registry.npm.taobao.orgcertificateexpired证书已过期解决方案

npm.taobao.org证书过期

网上查了下,淘宝最新的npm镜像地址更新了,换成了:

https://registry.npmmirror.com

好了,找到原因了,那就替换一下镜像地址吧

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

再次执行

npx create-react-app reactDemo

registry.npm.taobao.orgcertificateexpired证书已过期解决方案

create-react-app工程名不能有大写字母

初始化失败了,原来工程名字里不能有大写。

换一个,再来....

npx create-react-app react-demo

registry.npm.taobao.orgcertificateexpired证书已过期解决方案

工程初始化成功

启动看看效果吧

执行:

cd react-demo
npm start

registry.npm.taobao.orgcertificateexpired证书已过期解决方案

大功告成!

Hello World

有其他解决方案的小伙伴也交流一下哈