简体   繁体   中英

Application error after succeeded Heroku Build (Node + React App)

I created an React app (using CRA) with Nodejs backend. Now I tried hosting it. (I've hosted few apps with same stack but didn't faced any issues).

I'm starting both Nodejs and React app using concurrently module with npm run dev . But this time I'm getting an error and I can't figure out why.

This is what I get when I go the link.

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.

index.js
 const express = require('express'); const routes = require('./routes'); const app = express(); const port = 5000 || process.env.PORT; routes(app); if(process.env.NODE_ENV === 'production'){ app.use(express.static('client/build')); const path = require('path'); app.get("*", (req,res) => { res.sendFile(path.resolve(__dirname,'client','build','index.html')); }) } app.listen(port, () => console.log(`Server is running on port ${port}`));
package.json
 { "name": "check-market", "version": "1.0.0", "description": "This is a react-nodejs based crypto market checking app", "main": "index.js", "scripts": { "start": "node index.js", "server": "nodemon index.js", "test": "echo \\"Error: no test specified\\" && exit 1", "client": "npm run start --prefix client", "dev": "concurrently \\"npm run server\\" \\"npm run client\\"", "heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client" }, "author": "abcd", "license": "ISC", "dependencies": { "concurrently": "^3.5.1", "cryptocoins-icons": "^2.7.0", "express": "^4.16.2", "node-fetch": "^2.0.0", "nodemon": "^1.14.12" } }
heroku logs
2018-04-05T13:41:49.283535+00:00 app[web.1]: [1]2018-04-05T13:41:49.560174+00:00 app[web.1]: [0] Server is running on port 5000 2018-04-05T13:41:51.049613+00:00 app[web.1]: [1] Starting the development server... 2018-04-05T13:41:51.049625+00:00 app[web.1]: [1] 2018-04-05T13:41:51.202463+00:00 heroku[web.1]: State changed from starting to up 2018-04-05T13:42:00.969286+00:00 app[web.1]: [1] Compiled with warnings. 2018-04-05T13:42:00.969303+00:00 app[web.1]: [1] 2018-04-05T13:42:00.969584+00:00 app[web.1]: [1] ./src/components/currency_main.js 2018-04-05T13:42:00.969587+00:00 app[web.1]: [1] Line 49: Expected to return a value in arrow function array-callback-return 2018-04-05T13:42:00.969588+00:00 app[web.1]: [1] 2018-04-05T13:42:00.969590+00:00 app[web.1]: [1] Search for the keywords to learn more about each warning. 2018-04-05T13:42:00.969593+00:00 app[web.1]: [1] To ignore, add // eslint-disable-next-line to the line before. 2018-04-05T13:42:00.969594+00:00 app[web.1]: [1]2018-04-05T13:42:17.377067+00:00 heroku[router]: at=info method=GET path="/" host=cryptic-hollows-53642.herokuapp.com request_id=fa334992-ebb7-4a38-8c2d-e5c09849dcef fwd="112.134.75.196" dyno=web.1 connect=1ms service=13ms status=200 bytes=219 protocol=https 2018-04-05T13:42:18.397503+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=cryptic-hollows-53642.herokuapp.com request_id=e716c9cb-e910-4f98-8346-4195c6d623ca fwd="112.134.75.196" dyno=web.1 connect=0ms service=7ms status=200 bytes=219 protocol=https 2018-04-05T13:44:47.000000+00:00 app[api]: Build started by user thidasaone@gmail.com 2018-04-05T13:44:47.000000+00:00 app[api]: Build succeeded 2018-04-05T13:46:08.491686+00:00 app[api]: Deploy 0ae9d4f3 by user thidasaone@gmail.com2018-04-05T13:46:08.491686+00:00 app[api]: Release v8 created by user thidasaone@gmail.com2018-04-05T13:46:10.417551+00:00 heroku[web.1]: Restarting 2018-04-05T13:46:10.418403+00:00 heroku[web.1]: State changed from up to starting2018-04-05T13:46:12.169322+00:00 heroku[web.1]: Stopping all processes with SIGTERM2018-04-05T13:46:12.258942+00:00 heroku[web.1]: Process exited with status 143 2018-04-05T13:46:17.859328+00:00 heroku[web.1]: Starting process with command `npm run dev`2018-04-05T13:46:20.219087+00:00 app[web.1]:2018-04-05T13:46:20.219128+00:00 app[web.1]: > check-market@1.0.0 dev /app 2018-04-05T13:46:20.219130+00:00 app[web.1]: > concurrently "npm run server" "npm run client"2018-04-05T13:46:20.219132+00:00 app[web.1]:2018-04-05T13:46:20.817238+00:00 app[web.1]: [0] 2018-04-05T13:46:20.817262+00:00 app[web.1]: [0] > check-market@1.0.0 server /app 2018-04-05T13:46:20.817265+00:00 app[web.1]: [0] > nodemon index.js 2018-04-05T13:46:20.817267+00:00 app[web.1]: [0] 2018-04-05T13:46:20.865621+00:00 app[web.1]: [1] 2018-04-05T13:46:20.865626+00:00 app[web.1]: [1] > check-market@1.0.0 client /app 2018-04-05T13:46:20.865635+00:00 app[web.1]: [1] > npm run start --prefix client 2018-04-05T13:46:20.865636+00:00 app[web.1]: [1] 2018-04-05T13:46:21.154092+00:00 app[web.1]: [0] [nodemon] 1.14.12 2018-04-05T13:46:21.155353+00:00 app[web.1]: [0] [nodemon] to restart at any time, enter `rs` 2018-04-05T13:46:21.155695+00:00 app[web.1]: [0] [nodemon] watching: *.* 2018-04-05T13:46:21.156422+00:00 app[web.1]: [0] [nodemon] starting `node index.js` 2018-04-05T13:46:21.225033+00:00 app[web.1]: [1] 2018-04-05T13:46:21.225037+00:00 app[web.1]: [1] > client@0.1.0 start /app/client 2018-04-05T13:46:21.225039+00:00 app[web.1]: [1] > react-scripts start 2018-04-05T13:46:21.225041+00:00 app[web.1]: [1] 2018-04-05T13:46:21.390693+00:00 app[web.1]: [0] Server is running on port 5000 2018-04-05T13:46:22.929315+00:00 app[web.1]: [1] [HPM] Proxy created: function (pathname) { 2018-04-05T13:46:22.929329+00:00 app[web.1]: [1] return mayProxy(pathname) && pathname.match(context); 2018-04-05T13:46:22.929331+00:00 app[web.1]: [1] } -> http://localhost:5000 2018-04-05T13:46:22.940428+00:00 app[web.1]: [1] Starting the development server... 2018-04-05T13:46:22.940431+00:00 app[web.1]: [1] 2018-04-05T13:46:23.520069+00:00 heroku[web.1]: State changed from starting to up 2018-04-05T13:46:31.231306+00:00 heroku[router]: at=info method=GET path="/" host=cryptic-hollows-53642.herokuapp.com request_id=ec7762d5-3d9d-4512-96bf-5e51fd57e531 fwd="112.134.75.196" dyno=web.1 connect=1ms service=35ms status=304 bytes=150 protocol=https 2018-04-05T13:46:32.041938+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=cryptic-hollows-53642.herokuapp.com request_id=51901fca-b454-4e15-891f-54157d6ecffa fwd="112.134.75.196" dyno=web.1 connect=1ms service=74ms status=304 bytes=150 protocol=https 2018-04-05T13:46:34.656623+00:00 app[web.1]: [1] 2018-04-05T13:46:34.656609+00:00 app[web.1]: [1] Compiled with warnings. 2018-04-05T13:46:34.656627+00:00 app[web.1]: [1] Line 49: Expected to return a value in arrow function array-callback-return 2018-04-05T13:46:34.656629+00:00 app[web.1]: [1] 2018-04-05T13:46:34.656650+00:00 app[web.1]: [1] Search for the keywords to learn more about each warning. 2018-04-05T13:46:34.656625+00:00 app[web.1]: [1] ./src/components/currency_main.js 2018-04-05T13:46:34.656652+00:00 app[web.1]: [1] To ignore, add // eslint-disable-next-line to the line before. 2018-04-05T13:46:34.656654+00:00 app[web.1]: [1] 2018-04-05T13:47:01.000000+00:00 app[api]: Build started by user thidasaone@gmail.com 2018-04-05T13:48:18.696342+00:00 heroku[router]: at=info method=GET path="/" host=cryptic-hollows-53642.herokuapp.com request_id=9b941ec9-ac57-465f-8270-ff6b576e7a7e fwd="112.134.75.196" dyno=web.1 connect=1ms service=4ms status=304 bytes=150 protocol=https 2018-04-05T13:48:19.715353+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=cryptic-hollows-53642.herokuapp.com request_id=9dce4cdb-3251-4371-a6dc-17f5157c4c91 fwd="112.134.75.196" dyno=web.1 connect=1ms service=4ms status=200 bytes=219 protocol=https 2018-04-05T13:48:23.281435+00:00 heroku[web.1]: Restarting 2018-04-05T13:48:23.283219+00:00 heroku[web.1]: State changed from up to starting 2018-04-05T13:48:24.367174+00:00 heroku[web.1]: Stopping all processes with SIGTERM 2018-04-05T13:48:24.460758+00:00 heroku[web.1]: Process exited with status 143 2018-04-05T13:48:22.235400+00:00 app[api]: Deploy f9c11456 by user thidasaone@gmail.com 2018-04-05T13:48:22.235400+00:00 app[api]: Release v9 created by user thidasaone@gmail.com 2018-04-05T13:47:01.000000+00:00 app[api]: Build succeeded 2018-04-05T13:48:31.022921+00:00 heroku[web.1]: Starting process with command `npm start` 2018-04-05T13:48:32.988916+00:00 app[web.1]: 2018-04-05T13:48:32.988939+00:00 app[web.1]: > check-market@1.0.0 start /app 2018-04-05T13:48:32.988941+00:00 app[web.1]: > node index.js 2018-04-05T13:48:32.988943+00:00 app[web.1]: 2018-04-05T13:48:33.185499+00:00 app[web.1]: Server is running on port 5000 2018-04-05T13:49:31.116916+00:00 app[web.1]: Error waiting for process to terminate: No child processes 2018-04-05T13:49:31.093326+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 secondsof launch 2018-04-05T13:49:31.093493+00:00 heroku[web.1]: Stopping process with SIGKILL 2018-04-05T13:49:31.174105+00:00 heroku[web.1]: Process exited with status 22 2018-04-05T13:49:31.188588+00:00 heroku[web.1]: State changed from starting to crashed 2018-04-05T13:49:31.190801+00:00 heroku[web.1]: State changed from crashed to starting 2018-04-05T13:49:41.680073+00:00 heroku[web.1]: Starting process with command `npm start` 2018-04-05T13:49:44.021163+00:00 app[web.1]: 2018-04-05T13:49:44.021180+00:00 app[web.1]: > check-market@1.0.0 start /app 2018-04-05T13:49:44.021181+00:00 app[web.1]: > node index.js 2018-04-05T13:49:44.021183+00:00 app[web.1]: 2018-04-05T13:49:44.261412+00:00 app[web.1]: Server is running on port 5000 2018-04-05T13:50:24.659139+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=cryptic-hollows-53642.herokuapp.com request_id=19ee5172-d09e-4a14-bec5-7332c5b8b572 fwd="112.134.75.196" dyno= connect= service= status=503 bytes= protocol=https 2018-04-05T13:50:42.173853+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 secondsof launch 2018-04-05T13:50:42.173971+00:00 heroku[web.1]: Stopping process with SIGKILL 2018-04-05T13:50:42.278113+00:00 heroku[web.1]: Process exited with status 137 2018-04-05T13:50:42.292645+00:00 heroku[web.1]: State changed from starting to crashed 2018-04-05T13:50:44.109644+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=cryptic-hollows-53642.herokuapp.com request_id=457aceaf-7149-4cd8-aaf0-1e9746c2e7a9 fwd="112.134.75.196" dyno= connect= service= status=503 bytes= protocol=https 2018-04-05T13:50:46.073884+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=cryptic-hollows-53642.herokuapp.com request_id=6d2ed2ed-a2dc-4b77-80f1-099d442e16db fwd="112.134.75.196" dyno= connect= service= status=503 bytes= protocol=https 2018-04-05T13:50:55.112767+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=cryptic-hollows-53642.herokuapp.com request_id=51e6ee29-3f28-4dc1-bc69-b58604b6524b fwd="112.134.75.196" dyno= connect= service= status=503 bytes= protocol=https 2018-04-05T13:51:02.307944+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=cryptic-hollows-53642.herokuapp.com request_id=5e366ae1-6d66-4015-85ad-e407316d083f fwd="112.134.75.196" dyno= connect= service= status=503 bytes= protocol=https 2018-04-05T13:51:24.537650+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=cryptic-hollows-53642.herokuapp.com request_id=8483caf1-1e99-4735-a16e-8df0d09b3d20 fwd="112.134.75.196" dyno= connect= service= status=503 bytes= protocol=https 2018-04-05T13:51:27.770178+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=cryptic-hollows-53642.herokuapp.com request_id=28e8927c-21ac-44c5-84e5-093f55c95aeb fwd="112.134.75.196" dyno= connect= service= status=503 bytes= protocol=https

As I read in heroku logs, I know there's an issue (as it mentions). But I can't figure out what it is as what I've followed the same steps as before (same as I hosted other apps on Heroku)

Can anyone tell me what have I done wrong ?

PS : I've checked this and added Procfile and then I got an issue with React App saying Invalid Header File . So I removed it (as Heroku has made the process automatically sometime after the post)

And I checked with this as well but I don't think it'll be any help.

尝试通过你的应用程序 => 设置 => 显示配置变量 => 在其中添加PORT 5000来尝试将配置变量添加到你的 Heroku 应用程序中

I had the same exact issue, I have added the PORT 5000 as mentioned above, but it alone didn't resolve my issue.

Anyway by checking the build logs, I found the following error:

Error: Configuration property "mongoURI" is not defined

The production.json file was in .gitignore file, and by removing it from .gitignore and pushing it to Heroku the issue was resolved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM