【问题标题】:React application & GraphQl server deployment problem with Heroku使用 Heroku 反应应用程序和 GraphQl 服务器部署问题
【发布时间】:2024-01-21 13:49:01
【问题描述】:

我制作了一个与 prisma - graphql 服务器一起使用的 react 应用程序。服务器位于 react 应用程序内部。我想用 Heroku 部署它(第一次使用它)。当我部署到 Heroku 时,当我运行 heroku logs --tail

时出现此错误
020-06-12T14:10:04.296156+00:00 heroku[web.1]: Process exited with status 0
2020-06-12T14:10:04.332716+00:00 heroku[web.1]: State changed from starting to crashed
2020-06-12T14:10:04.335407+00:00 heroku[web.1]: State changed from crashed to starting
2020-06-12T14:10:15.424387+00:00 heroku[web.1]: Starting process with command `npm start`
2020-06-12T14:10:17.947363+00:00 app[web.1]:
2020-06-12T14:10:17.947379+00:00 app[web.1]: > business-scheduler@0.1.0 start /app
2020-06-12T14:10:17.947379+00:00 app[web.1]: > react-scripts start
2020-06-12T14:10:17.947379+00:00 app[web.1]:
2020-06-12T14:10:20.724920+00:00 app[web.1]: ℹ 「wds」: Project is running at http://172.19.52.78/
2020-06-12T14:10:20.725386+00:00 app[web.1]: ℹ 「wds」: webpack output is served from
2020-06-12T14:10:20.725577+00:00 app[web.1]: ℹ 「wds」: Content not from webpack is served from /app/public
2020-06-12T14:10:20.725681+00:00 app[web.1]: ℹ 「wds」: 404s will fallback to /
2020-06-12T14:10:20.725971+00:00 app[web.1]: Starting the development server...
2020-06-12T14:10:20.725972+00:00 app[web.1]:
2020-06-12T14:10:20.803624+00:00 heroku[web.1]: Process exited with status 0
2020-06-12T14:10:20.835709+00:00 heroku[web.1]: State changed from starting to crashed
2020-06-12T14:27:07.241917+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=appoint-scheduler.herokuapp.com request_id=4a6d7846-488a-4a57-bd76-ee5b84c197fc fwd="94.227.127.41" dyno= connect= service= status=503 bytes= protocol=https
2020-06-12T14:27:07.688859+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=appoint-scheduler.herokuapp.com request_id=83928da3-bc4a-44f5-83fb-66a7c5b2611d fwd="94.227.127.41" dyno= connect= service= status=503 bytes= protocol=https

我在我的项目中使用 yarn 而不是 npm 有人知道我需要做什么才能部署我的项目吗? 因为我的项目没有在 heroku 上运行,因为我在尝试打开已部署的版本时得到了这个

Application error
An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command
heroku logs --tail

【问题讨论】:

    标签: reactjs heroku yarnpkg heroku-cli prisma-graphql


    【解决方案1】:

    我认为问题在于您正在尝试在 heroku 上启动反应开发服务器。您的 React 应用程序应作为静态 js 包提供,该包在您运行生产构建 cmd npm run build 后生成。

    看看https://github.com/mars/create-react-app-buildpack,它只为这个用例而开发,使它更容易。

    如果您尝试部署整个堆栈(react + prisma + graphql 服务器)...请查看此post,其中详细介绍了它。

    希望这会有所帮助!

    【讨论】:

      最近更新 更多