【发布时间】:2020-07-17 13:31:29
【问题描述】:
我花了 6 多个小时试图弄清楚为什么这不会在 Heroku 上成功运行。它在本地运行,但是当我部署到 Heroku 时,我得到以下日志,基本上只是说应用程序崩溃了。我安装了 Heroku 的 CLI 并试图在其中找到一个更有帮助的错误,但无济于事。还有其他人有什么想法或建议吗?
代码 => https://github.com/ghughes13/react-todo-list
https://ghughes-react-todo-list.herokuapp.com/
2020-04-05T14:46:31.351885+00:00 app[web.1]: [34mℹ[39m [90m「wds」[39m: Project is running at http://172.18.176.170/
2020-04-05T14:46:31.355002+00:00 app[web.1]: [34mℹ[39m [90m「wds」[39m: webpack output is served from
2020-04-05T14:46:31.355159+00:00 app[web.1]: [34mℹ[39m [90m「wds」[39m: Content not from webpack is served from /app/public
2020-04-05T14:46:31.355252+00:00 app[web.1]: [34mℹ[39m [90m「wds」[39m: 404s will fallback to /
2020-04-05T14:46:31.355468+00:00 app[web.1]: Starting the development server...
2020-04-05T14:46:31.355470+00:00 app[web.1]:
2020-04-05T14:46:31.498661+00:00 heroku[web.1]: State changed from starting to crashed
2020-04-05T14:46:33.839876+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=ghughes-react-todo-list.herokuapp.com request_id=199836cb-d38a-4941-aee7-fc5e5deba5dc fwd="97.99.41.155" dyno= connect= service= status=503 bytes= protocol=https
2020-04-05T14:46:34.454912+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=ghughes-react-todo-list.herokuapp.com request_id=b905fff4-83bf-4319-801a-c2c4f1d7a4e1 fwd="97.99.41.155" dyno= connect= service= status=503 bytes= protocol=https
"name": "todo-list",
"version": "0.1.0",
"private": true,
"dependencies": {
"@reach/router": "^1.3.3",
"axios": "^0.19.2",
"mongodb": "^3.5.2",
"mongodb-client-encryption": "^1.0.1",
"mongoose": "^5.8.11",
"reach": "^1.0.1",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react-scripts": "^3.4.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
【问题讨论】:
-
devDependencies 在 Heroku 上被剥离。此外,开发服务器(顾名思义)用于 dev,而不是 prod。参见例如stackoverflow.com/q/41932041/3001761 进行最小修复。
-
我有什么作为开发依赖项?
-
您如何尝试托管您的 React 应用程序?将 webpack 构建文件夹部署为静态内容或在主机上使用节点服务器运行应用程序?另外,我建议您尝试使用firebase。与 heroku 不同,站点始终保持实时状态,而且部署很简单。
-
我使用 heroku/nodejs 作为构建包。亲爱的,我肯定会研究火力基地。谢谢。