在uniapp项目中使用yarn或者npm安装包失败
报错说明
- 在常规vue项目中使用npm或者yarn下载包可以正常使用
- 但是在uniapp项目中,使用yarn或者npm下载包报错
- 报错如下
- info No lockfile found.
[1/4] Resolving packages...
error Error: certificate has expired
at TLSSocket.onConnectSecure (node:_tls_wrap:1539:34)
at TLSSocket.emit (node:events:513:28)
at TLSSocket._finishInit (node:_tls_wrap:953:8)
at TLSWrap.ssl.onhandshakedone (node:_tls_wrap:734:12)
info Visit yarnpkg.com/en/docs/cli… for documentation about this command.
- 最开始以为是下载源的问题,但是我本来就是淘宝镜像源
解决方案
经常查询和验证,发现是 HTTPS 证书验证失败 的原因
- 第一步:输入命令 yarn config list
查看strct-ssl的值,默认它的值为true

- 第二步:输入命令 yarn config set strict-ssl false
将strict-ssl的值设置为false即可
