0
votes

I already have one app running on Heroku just fine which I created a few weeks ago for the first time.

Here is the git repo for the functioning app - https://github.com/Sean-99-04/basic

However when I try to run my newest app, it does not work. It builds fine, but gives an application error when ran.

Here is the git repo for that - https://github.com/Sean-99-04/History-Blog

Also I am runnnig this through GitHub, not through Heroku CLI.

I have been searching online for the last 3 hours for answers and here are some things mentioned which I made sure to unclude:

  • Procfile with code "web:node ./server.js"
  • package.json with code "script": {"start": "node server.js"}
  • In server.js I have process.env.PORT and all other necessary process.env's

I greatly appreciate any help and thank you in advance.

This is the error in logs:

2021-01-11T16:50:16.910561+00:00 app[web.1]: npm ERR! Failed at the [email protected] start script.

2021-01-11T16:50:16.910689+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

2021-01-11T16:50:16.915638+00:00 app[web.1]:

2021-01-11T16:50:16.915831+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:

2021-01-11T16:50:16.915958+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-01-11T16_50_16_911Z-debug.log

2021-01-11T16:50:16.988688+00:00 heroku[web.1]: Process exited with status 1

2021-01-11T16:50:17.025320+00:00 heroku[web.1]: State changed from starting to crashed

2021-01-11T16:50:17.966848+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=history-blog.herokuapp.com request_id=f274158b-5399-49ab-97d9-5a83bb387a13 fwd="95.147.237.100" dyno= connect= service= status=503 bytes= protocol=https

1
What is the error? - Zac Anger
Just edited original comment with error. - Shaun
Does there happen to be anything more before that? You could try changing your Procfile to be web: npm start --loglevel silly to get more log output. - Zac Anger
To clarify. Are you asking me to change web:node ./server.js to web: npm start --loglevel silly or add it? - Shaun
Yes, if you can. That would give you a lot more log output. - Zac Anger

1 Answers

1
votes

As mentioned in the comments, the failure was caused by trying to loading dotenv. The reason that happened despite Heroku's default NODE_ENV being production is that you're assigning in the check, which returns the string development, which is truthy — so it gets loaded.

What you have: if ((process.env.NODE_ENV = "development")) {

What you want: if (process.env.NODE_ENV === "development") {