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…
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!