【发布时间】:2017-05-20 16:00:07
【问题描述】:
我正在尝试让 mern 应用程序在 heroku 上运行。但是现在,即使修复节点服务器也足够了。
这是我已经做过的。
- 在 heroku 中创建应用并将我的项目推送到它。
- 添加了 mLab 数据库链接。 (在本地服务器上正常运行)
- 将开发依赖项放在依赖项上。
- 尝试通过 heroku CLI 运行“heroku run node server.js”。然后它记录为服务器在端口 8080 上启动。
但我无法访问 API 或 Web 界面。 我的应用网址 = http://travelaround.herokuapp.com
请注意我的网络应用程序是使用 create-react-app 创建的 我在 heroku 的日志,
2017-05-14T17:17:50.113754+00:00 heroku[api.1]: Process exited with status 0
2017-05-14T17:17:52.979224+00:00 heroku[api.1]: Starting process with command `nodemon server.js`
2017-05-14T17:17:53.538796+00:00 heroku[api.1]: State changed from starting to up
2017-05-14T17:17:55.154398+00:00 app[api.1]: [33m[nodemon] 1.11.0[39m
2017-05-14T17:17:55.156364+00:00 app[api.1]: [33m[nodemon] to restart at any time, enter `rs`[39m
2017-05-14T17:17:55.156522+00:00 app[api.1]: [33m[nodemon] watching: *.*[39m
2017-05-14T17:17:55.157062+00:00 app[api.1]: [32m[nodemon] starting `node server.js`[39m
2017-05-14T17:17:55.982045+00:00 app[api.1]: Database connection Established at mongodb://test:asd123@ds139791.mlab.com:39791/travelaround
2017-05-14T17:17:56.008148+00:00 app[api.1]: api running on port 3000
2017-05-15T14:22:19.692618+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=travelaround.herokuapp.com request_id=b46a031e-db9d-4cac-93fa-ffd73f51e5f3 fwd="93.65.70.107" dyno= connect= service= status=503 bytes= protocol=http
2017-05-15T14:22:20.297803+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=travelaround.herokuapp.com request_id=9ca4977c-b45e-4f3e-b98a-1034855e8c4f fwd="93.65.70.107" dyno= connect= service= status=503 bytes= protocol=http
【问题讨论】:
-
进入应用程序文件夹并运行
heroku logs。结果如何? -
嗨@Corrado 添加了日志! :)
-
您似乎没有运行测功机。要修复它,请尝试运行
heroku ps:scale web=1并重新启动您的 heroku 应用程序,理论上应该可以工作! -
另外,我认为您可能想更改
npm start命令以简单地运行 node,而不是 nodemon,因为我认为它可能会弄乱一些 heroku 的东西。只需将 nodemon 命令移动到类似npm dev... -
嗨 Corrado,我尝试通过 CLI 运行 node server.js ;结果还是一样!我应该尝试更改脚本做什么? npm 运行启动开发?也试过了!
标签: node.js reactjs heroku web-deployment