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

React项目安装依赖后崩溃求助(含error:0308010C错误)

解决Error: error:0308010C:digital envelope routines::unsupported问题

这个错误是Node.js v17+版本采用OpenSSL 3.0加密算法,而旧版create-react-app的react-scripts不兼容导致的,给你几个可行的解决办法:

  • 临时启动方案:修改package.json中的start脚本,添加兼容参数

    • 类Unix系统(Mac/Linux):
      "scripts": {
        "start": "NODE_OPTIONS=--openssl-legacy-provider react-scripts start",
        "build": "NODE_OPTIONS=--openssl-legacy-provider react-scripts build",
        "test": "react-scripts test",
        "eject": "react-scripts eject"
      }
      
    • Windows系统:
      "scripts": {
        "start": "set NODE_OPTIONS=--openssl-legacy-provider && react-scripts start",
        "build": "set NODE_OPTIONS=--openssl-legacy-provider && react-scripts build",
        "test": "react-scripts test",
        "eject": "react-scripts eject"
      }
      

    修改后重新执行npm start即可。

  • 降级Node.js版本:使用版本管理工具(比如nvm)切换到v16.x系列的LTS版本(例如v16.20.0),这个版本使用OpenSSL 1.1.1,不会触发该兼容性问题。

  • 更新react-scripts版本:如果项目允许,升级到最新版的react-scripts,执行命令:

    npm install react-scripts@latest
    

    更新完成后重启项目即可。

内容的提问来源于stack exchange,提问作者s0ftlaa

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.09 15:44:50