解决微信小程序开发初始化npm install包失败
报错信息
npm ERR! code CERT_HAS_EXPIRED npm ERR! errno CERT_HAS_EXPIRED npm ERR! request to https://registry.npm.taobao.org/@vant/weapp/download/@vant/weapp-1.6.3.tgz failed, reason: certificate has expired npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Administrator\AppData\Local\npm-cache\_logs\2025-09-05T03_37_07_945Z-debug-0.log
分析:
这个错误非常明确:你正在使用的淘宝 NPM 镜像(
https://registry.npm.taobao.org
)其 SSL 证书早已过期,因此 npm 在安装依赖时拒绝连接,抛出CERT_HAS_EXPIRED
错误。
解决步骤
1.更改镜像地址
npm config set registry https://registry.npmmirror.com
2.清理缓存
npm cache clean --force
3.清理「lock 文件里写死了旧 tarball 地址」重要!!!!
del package-lock.json
4.重新安装
npm install