执行 yarn install 抛出 unable to verify the first certificate 错误

本文将介绍怎样解决执行 yarn install 抛出的 unable to verify the first certificate 错误。

在执行 yarn install 时抛出了 unable to verify the first certificate 错误,详细错误信息如下图:

执行 yarn install 抛出 unable to verify the first certificate 错误

根据错误信息可知,这是 HTTPS 证书验证失败导致的。

可使用“yarn config list”命令查看 yarn 的配置清单,如下:

C:\Users\Administrator>yarn config list
yarn config v1.22.10
warning package.json: No license field
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.yarnpkg.com',
  'strict-ssl': true,
  'user-agent': 'yarn/1.22.10 npm/? node/v14.14.0 win32 x64',
  lastUpdateCheck: 1604624916256
}
info npm config
{
  registry: 'http://registry.npm.taobao.org/',
  'strict-ssl': false
}
Done in 0.17s.

在 info yarn config 信息中, 'strict-ssl' 为 true,表示需要验证 HTTPS 证书。我们可以将 'strict-ssl' 设置为 false,跳过 HTTPS 证书验证。如下:

C:\Users\Administrator>yarn config set strict-ssl false
yarn config v1.22.10
warning package.json: No license field
success Set "strict-ssl" to "false".
Done in 0.17s.

C:\Users\Administrator>yarn config get strict-ssl
warning package.json: No license field
false

然后再试试“yarn install”命令。

学习从来无捷径,循序渐进登高峰。 —— 高永祚
1 不喜欢 收藏
说说我的看法 -
全部评论()
没有评论