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

如何在本地运行从StackBlitz导出的React项目?解决index.html缺失报错

修复方案

报错原因是react-scripts默认会在项目的public目录下查找index.html,但你的GitHub仓库中该文件位于项目根目录,导致启动时找不到文件。可以通过以下两种方式修复:

  • 方法一:调整文件位置(推荐)
    将项目根目录下的index.html移动到public文件夹中,匹配create-react-app的默认目录规范。

  • 方法二:修改启动配置
    若不想移动文件,可修改package.json里的scripts字段,手动指定index.html的路径:

    "scripts": {
      "start": "react-scripts start --index ./index.html",
      "build": "react-scripts build --index ./index.html",
      "test": "react-scripts test",
      "eject": "react-scripts eject"
    }
    

完成操作后,重新执行yarn start即可正常启动项目。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.22 11:27:28