You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.30 01:37:05