报错内容:
npm ERR! code CERT_HAS_EXPIRED
npm ERR! errno CERT_HAS_EXPIRED
npm ERR! request to https://registry.npm.taobao.org/cnpm failed, reason: certificate has expired
npm ERR! A complete log of this run can be found in:
npm ERR! D:\vs\_logs\2024-05-07T12_40_11_613Z-debug-0.log
解决办法:
1.清除npm缓存
npm cache clean --force
2.禁用SSL
npm config set strict-ssl false
3.重新执行命令
如果还报错第三步还报错,进入第四步
4.手动设置npm镜像源
npm config set registry https://registry.npm.taobao.org/
再次尝试重新执行命令,如果还报错再进行第五步
5.更新npm和Node.js
npm install -g npm@latest
6.更新操作系统时间
sudo ntpdate -u time.nist.gov
7.更新根证书
- 在 Linux 上,更新 ca-certificates 包。
- 在 macOS 上,更新 Keychain 中的根证书。
- 在 Windows 上,手动下载并安装最新的根证书。