yarn 安装依赖报错 error Error: certificate has expired

469 阅读1分钟

yarn安装依赖执行报错:error Error: certificate has expired

yarn install v1.22.21
info No lockfile found.
[1/4] Resolving packages...
error Error: certificate has expired
    at TLSSocket.onConnectSecure (node:_tls_wrap:1530:34)
    at TLSSocket.emit (node:events:390:28)
    at TLSSocket._finishInit (node:_tls_wrap:944:8)
    at TLSWrap.ssl.onhandshakedone (node:_tls_wrap:725:12)

解决方案

1. 查看配置

yarn config list
yarn config v1.22.21
info yarn config
{
  'version-tag-prefix': 'v',
  'version-git-tag': true,
  'version-commit-hooks': true,
  'version-git-sign': false,
  'version-git-message': 'v%s',
  'init-version': '1.0.0',
  'init-license': 'MIT',
  'save-prefix': '^',
  'bin-links': true,
  'ignore-scripts': false,
  'ignore-optional': false,
  registry: 'https://registry.npm.taobao.org/',
  'strict-ssl': true,
  'user-agent': 'yarn/1.22.21 npm/? node/v16.13.1 win32 x64',
  disturl: 'https://npmmirror.com/dist',
  lastUpdateCheck: 1708583616621,
  'sass-binary-site': 'http://npm.taobao.org/mirrors/node-sass'
}
info npm config
{
  registry: 'https://registry.npm.taobao.org/',
  'always-auth': true,
  home: 'https://yarnpkg.com'
}

2. 将strict-ssl设为false

设置后重新运行yarn,即可安装成功。

附-缓存清理方式

npm

PS F:\eh\codes\bird\wb_app> npm cache clear --force
npm WARN using --force Recommended protections disabled.
PS F:\eh\codes\bird\wb_app> npm cache verify       
Cache verified and compressed (~\AppData\Local\npm-cache\_cacache)
Content verified: 0 (0 bytes)
Index entries: 0
Finished in 0.027s

yarn

PS F:\eh\codes\bird\wb_app> yarn cache clean
yarn cache v1.22.21
success Cleared cache.
Done in 0.05s.