MERN 应用程序 Heroku 构建失败 "Could not find a required file. Name: index.html"

MERN app Heroku build failed "Could not find a required file. Name: index.html"

我使用 create-react-app 构建了我的应用程序并使用 node.js 和 express 创建了后端..我使用 build 命令获取了 react 应用程序的生产版本并使其与我的后端一起工作并且在本地主机上一切正常..这就是我的文件结构:

当我尝试将其部署到 heroku 时,构建失败并出现此错误

 Could not find a required file.
         Name: index.html
         Searched in: /tmp/build_839c6cd8/public
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! proj@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the proj@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
 Some possible problems:
       
       - Node version not specified in package.json
         https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version

为什么构建失败?我做错了什么?

编辑:heroku 是否需要特定的文件结构或其他内容?它似乎无法处理“构建”文件夹..我在项目的根目录(外部构建)中创建了一个 public 目录并将我的 index.html 移到了它,这解决了这个文件的问题..现在当我尝试部署它时说

Could not find a required file.
         Name: index.js

..所以现在“丢失”的文件是js文件..我现在该怎么办?创建一个新的 src 目录并将我的 js 移动到它?这是一些废话..这是怎么回事?

呃“修复了吗?”..似乎 heroku 试图 运行 create-react-app 本身的构建脚本,而不是 运行 按原样 运行 我的项目文件..我不得不从 package.json 文件中删除 create-react-app 脚本,现在一切都按预期工作了。虽然我不明白为什么会这样,但如果有 heroku 背景的人能解释一下那就太好了..

tl;dr:解决方案是从 package.json

中删除 create-react-app 脚本