Has anyone else run into trouble trying to do this? I can deploy with heroku local web fine but deploying to heroku and the app crashes every time. This is infuriating
Iāve encountered hiccups with it before.
Can you share the relevant bits? Iām happy to help troubleshoot
Hey, is your code on Github? In that case you should be able to just pull it in. Make sure your port is set correct.
I really donāt understand. I deployed an app successfully a few days ago, although it took a while. Iām pretty sure Iāve done everything 100% the same this time and itās failing every time.
I basically have a build setup where I run npm build to build all my files into a dist/ directory and then I push everything to git and deploy to heroku with git push heroku master. At this point if I run heroku local web it works fine. But after deploying to heroku the application has an error everytime I open it: āApp crashedā method=GET. Itās detecting itās a node app and running npm start which babel-node starts my server file. But I guess something in the above isnāt working.
Iāve checked the express port, itās listening on process.env.PORT. Iāve checked the dependencies Iām including. I really donāt know why itās not working.
Do the logs give any information?
Your app is more complex than anything Iāve done before, but looking at the source code - I wonder if there is some git deployment issue arising from the build pipeline you have? Like, maybe the dist
folder gets cached and updates in weird ways when you make changes in src
? That might explain why the first deployment worked but subsequent ones didnāt? (Obviously just spitballing, here!)
hang on I might have found itā¦
T_T
Okay so I didnāt quite figure it out but I reduced it to Heroku is having an issue loading values from a .env file I have in my project root. I havenāt run into this issue before? My server file and routes inside a routes folder are both trying to access some values in .env. Any idea how I should config this so it works when I deploy to Heroku? I am trying to just their cli tool instead of their site, btw.
Have you set the appropriate config variables in Heroku?
I think there is a way to conditionally load the .env depending on whether the environment is āproductionā or ādevelopmentā. Iāve never done it myself, but I think you can use NODE_ENV (Heroku defaults NODE_ENV to āproductionā when you deploy).
Not sure if this helps, but I found this trying to find more to do with the production environment side of things:
Just got it working finallyā¦ yes I had to load all the .env values directly and then be sure I updated my callback URLs correctly everywhere. For some reason I wasnāt able to load them successfully using dotenv although I have done that beforeā¦ not clear on why but just happy to see the thing deployed and running now after 4 some hours of my mind melting trying to figure it outā¦
Anywayā¦ now we can all trade books together I pray you donāt find any bugs
Btw thanks for mentioning the logs I didnāt know you could get more info than the logs displaying on herokuās website. Displaying the logs from the command line led me to the error about the .env file and then gradually to the solution.
Thanks everyone for such quick replies earlier!
Hey am also having issues. after deployind i get this error; Error waiting for process to terminate: No child processes
Although Iām (a little) surprised that dotenv didnāt work, the point of having ENV variables in Heroku separated from your git-based code is that itās generally good practice not to have them in git at all - this is a common place to store access keys, tokens, passwords and the like.