Node app on Heroku - getting “Application Error”

Node app on Heroku - getting “Application Error”
0.0 0

#1

Greeting, campers!

I have looked through the similar topics and have so far been unable to resolve my deployment issue.

when I’ve deployed it I get an application error. tried to delete it and deploy it again but nothing happened.

https://firetodo.herokuapp.com/


#2

If you are the application owner, check your logs for details.


#3

this is log file:

2018-01-24T11:20:22.865825+00:00 app[web.1]: npm ERR! missing script: start
2018-01-24T11:20:22.873590+00:00 app[web.1]:
2018-01-24T11:20:22.873869+00:00 app[web.1]: npm ERR! A complete log of this run
can be found in:
2018-01-24T11:20:22.873936+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2018-01-24T11_20_22_867Z-debug.log
2018-01-24T11:20:22.931940+00:00 heroku[web.1]: Process exited with status 1
2018-01-24T11:20:22.945935+00:00 heroku[web.1]: State changed from starting to crashed
2018-01-24T11:20:36.935697+00:00 heroku[router]: at=error code=H10 desc=“App crashed” method=GET path="/" host=firetodo.herokuapp.com request_id=5de4a770-d007-42e6-9450-7edbf746d064 fwd=“197.39.19.110” dyno= connect= service= status=503 bytes= protocol=https
2018-01-24T11:20:38.405704+00:00 heroku[router]: at=error code=H10 desc=“App crashed” method=GET path="/favicon.ico" host=firetodo.herokuapp request_id=611d73af-f491-4ea8-ad41-9625c2e28f5f fwd=“197.39.19.110” dyno= connect= service= status=503 bytes= protocol=https
2018-01-24T11:45:29.690322+00:00 heroku[router]: at=error code=H10 desc=“App crashed” method=GET path="/" host=firetodo.herokuapp request_id=e6977494-b030-48c8-8f79-e95d05711700 fwd=“197.39.19.110” dyno= connect= service= status=503 bytes= protocol=https
2018-01-24T11:45:34.106377+00:00 heroku[router]: at=error code=H10 desc=“App crashed” method=GET path="/favicon.ico" host=firetodo.herokuapp request_id=09d16c24-35ff-4930-a7c2-ff2c0fa15c08 fwd=“197.39.19.110” dyno= connect= service= status=503 bytes= protocol=https
2018-01-24T11:45:41.177551+00:00 heroku[router]: at=error code=H10 desc=“App crashed” method=HEAD path="/" host=firetodo.herokuapp request_id=390ba626-8c8c-4909-a3f4-6d8ff21f6a3a fwd=“174.138.37.36” dyno= connect= service= status=503 bytes= protocol=https


#4

You need a start script in your package.json file. Something like:

"scripts": {
    "start": "node server.js"
}

#5

now I’m getting this

2018-01-24T12:02:14.220261+00:00 app[web.1]: npm ERR! Exit status 1
2018-01-24T12:02:14.221027+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2018-01-24T12:02:14.220561+00:00 app[web.1]: npm ERR!
2018-01-24T12:02:14.220766+00:00 app[web.1]: npm ERR! Failed at the to-do-app@1.0.0 start script.
2018-01-24T12:02:14.234884+00:00 app[web.1]:
2018-01-24T12:02:14.235228+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2018-01-24T12:02:14.235401+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2018-01-24T12_02_14_222Z-debug.log
2018-01-24T12:02:14.303238+00:00 heroku[web.1]: Process exited with status 1
2018-01-24T12:02:14.312646+00:00 heroku[web.1]: State changed from starting to crashed
2018-01-24T12:02:20.609095+00:00 heroku[router]: at=error code=H10 desc=“App crashed” method=GET path="/" host=firetodo.herokuapp.com request_id=968b7a24-2faf-4378-b8ba-9749ec3ee2ea fwd=“197.39.19.110” dyno= connect= service= status=503 bytes= protocol=https
2018-01-24T12:02:21.884234+00:00 heroku[router]: at=error code=H10 desc=“App crashed” method=GET path="/favicon.ico" host=firetodo.herokuapp.com request_id=b30b00c4-aca3-4edc-9105-a46bd3757343 fwd=“197.39.19.110” dyno= connect= service= status=503 bytes= protocol=https


#6

Does it work locally when you run npm start? And what does your package.json look like now?


#7

Yes, it works locally, and this is my package.json content:

{
“name”: “to-do-app”,
“version”: “1.0.0”,
“description”: “Simple To-Do App”,
“main”: “app.js”,
“scripts”: {
“start”: “node server.js”
},
“author”: “wael”,
“license”: “ISC”,
“dependencies”: {
“body-parser”: “^1.18.2”,
“ejs”: “^2.5.7”,
“express”: “^4.16.2”,
“mongoose”: “^5.0.1”
}
}


#8

If you named your main file app.js, you should also use node app.js inside the start script.


#9

Good we are getting close to solve it, now I’m getting this:

2018-01-24T12:19:06.563946+00:00 heroku[web.1]: State changed from crashed to starting
2018-01-24T12:19:09.001583+00:00 heroku[web.1]: Starting process with command npm start
2018-01-24T12:19:11.473433+00:00 app[web.1]:
2018-01-24T12:19:11.473449+00:00 app[web.1]: > to-do-app@1.0.0 start /app
2018-01-24T12:19:11.473451+00:00 app[web.1]: > node app.js
2018-01-24T12:19:11.473452+00:00 app[web.1]:
2018-01-24T12:19:12.385281+00:00 heroku[web.1]: State changed from starting to up
2018-01-24T12:19:12.291926+00:00 app[web.1]: Express server listening on port 3900 in production mode
2018-01-24T12:19:13.578005+00:00 heroku[router]: at=info method=GET path="/" host=firetodo.herokuapp.com request_id=bb55228c-ca57-4e30-bf87-be53aa1a6d8c fwd=“197.39.19.110” dyno=web.1 connect=0ms service=60ms status=404 bytes=383 protocol=https
2018-01-24T12:19:14.885440+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=firetodo.herokuapp.com request_id=64b16bb7-8a7f-4583-ab4c-0a4243c2445a fwd=“197.39.19.110” dyno=web.1 connect=0ms service=4ms status=404 bytes=394 protocol=https
2018-01-24T12:19:15.873746+00:00 heroku[router]: at=info method=GET path="/" host=firetodo.herokuapp request_id=7071c9eb-d275-48d6-ba1c-46d6fb0604ef fwd=“197.39.19.110” dyno=web.1 connect=0ms service=10ms status=404 bytes=383 protocol=https


#10

Well, it is working then, right?


#11

no now it says: "Cannot GET / " when I go to the app link

https://firetodo.herokuapp.com/


#12

I would have to see the code, do you have it on GitHub or somewhere online?


#13

#14

You don’t specify what to do on specific routes. You only use ./public as static folder and set ejs as view engine.

And that is working. Try going to /assets/logo.png (a file in your static folder) or to /todo (a view).


#15

I can’t understand what should I do now? Can you explain more?


#16

You only have this get route: app.get('/todo', function(req, res). So only when you go to /todo your express server will actually do something. If you want to always render the todo view you can use: app.get('*', function(req, res)

Or if you only want / and /todo to render the todo view, you can add this route:

app.get('/', function(req, res){
   res.redirect('/todo');
});

#17

Oh my god it worked !!! thank you very much for your tips