执行yarn安装时遇unable to get local issuer certificate错误求助
Docker构建时yarn install出现证书错误
错误日志
[builder 4/6] RUN yarn: #10 0.574 yarn install v1.22.19 #10 0.704 [1/4] Resolving packages... #10 1.587 [2/4] Fetching packages... #10 2.112 error An unexpected error occurred: "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.18.9.tgz: unable to get local issuer certificate". #10 2.112 info If you think this is a bug, please open a bug report with the information provided in "/app/yarn-error.log". #10 2.112 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command. ------ executor failed running [/bin/sh -c yarn]: exit code: 1
已尝试的解决命令
yarn install --ignore-engines --ignore-platform yarn config set "strict-ssl" false -g yarn config set enableStrictSsl false
可行解决方案
- 在Dockerfile中执行yarn命令前,临时关闭strict-ssl再执行安装:
或者直接用命令行参数覆盖配置:RUN yarn config set strict-ssl false && yarn installRUN yarn install --strict-ssl false - 若处于企业内网环境,需将内部CA证书添加到容器信任列表:
- 把CA证书文件(如
ca.crt)复制到容器证书目录:COPY ca.crt /usr/local/share/ca-certificates/ RUN update-ca-certificates - 再执行
yarn install,无需关闭strict-ssl
- 把CA证书文件(如
- 检查构建网络是否走代理,若有代理需配置对应证书:
RUN yarn config set proxy http://your-proxy:port RUN yarn config set https-proxy http://your-proxy:port RUN yarn config set cafile /path/to/proxy-ca.crt && yarn install
内容的提问来源于stack exchange,提问作者PCA
相关产品推荐
相关产品推荐

