GitHub推送部署Firebase Hosting时出现error:0308010C错误求助
解决GitHub Actions部署React项目时的
error:0308010C:digital envelope routines::unsupported错误 这个错误是因为GitHub Actions中使用的Node.js版本(通常是较新的17+版本)默认启用了OpenSSL 3.0的新算法,而你的react-scripts版本不兼容导致的。以下是几种可行的解决方法:
指定Node.js版本为16.x
在你的GitHub Actions工作流文件(通常是.github/workflows/deploy.yml这类文件)中,设置Node.js版本为16,该版本不会触发该兼容性问题:- name: Use Node.js 16.x uses: actions/setup-node@v3 with: node-version: '16.x'修改build命令添加兼容参数
在项目的package.json中,修改scripts里的build命令,添加NODE_OPTIONS="--openssl-legacy-provider":"scripts": { "build": "NODE_OPTIONS=\"--openssl-legacy-provider\" react-scripts build" }这样GitHub Actions运行
yarn build时会使用旧的加密算法,避免报错。升级react-scripts到最新版本
如果项目依赖允许,直接升级react-scripts到v5及以上版本,新版本已经适配了高版本Node.js的加密算法要求:yarn upgrade react-scripts@latest
内容的提问来源于stack exchange,提问作者Matt102065
相关产品推荐
相关产品推荐

