yarn install出现error Error: certificate has expired异常

https://github.com/yarnpkg/yarn/issues/9032

出现的错误日志信息:

yarn install v1.22.22
[2/4] Fetching packages...
info There appears to be trouble with your network connection. Retrying...
error Error: certificate has expired
    at TLSSocket.onConnectSecure (node:_tls_wrap:1679:34)
    at TLSSocket.emit (node:events:518:28)
    at TLSSocket._finishInit (node:_tls_wrap:1078:8)
    at ssl.onhandshakedone (node:_tls_wrap:864:12)
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...

解决办法三步走:

  1. 检查npm或yarn指向的npm仓库地址是否有效(命令:yarn config set registry "https://registry.npmmirror.com"),https证书是否有效。
  2. (不建议,可跳过)关闭strict-ssl,yarn config set strict-ssl false
  3. 删除依赖锁定文件,如yarn.lock文件。
    最后,重新安装依赖即可。
posted @ 2025-11-26 11:09  星小梦  阅读(89)  评论(0)    收藏  举报