This post is for everyone learning React out there. Weekend warriors, boot campers, and autodidacts.. I’m here for you! They told you not to do it, but you did it anyway.
You used create-react-app followed by
npm run eject and now your app doesn’t work on Heroku. You google and find that the maintainers of create-react-app have no answers for you. Can you blame them? They are busy! So here we go:
Make sure you are running the right build pack
If you have already deployed your app created with create-react-app to Heroku, you are probably using the create-react-app-buildpack. After ejecting, you will need to remove that buildpack and add the heroku/nodejs buildpack instead.
Update your Procfile
This one is tricky because the create-react-app maintainers don’t have the time to debug this Heroku issue for you. Also, they told you not to eject!
But you did. So you need to update your procfile to something like
web: node scripts/start.js instead of
web: react-scripts start.
That should do it. Don’t forget to take a look at your GitHub repo along the way and make sure your most recent changes made it up there. That may sound obvious, but it is something that can easily be overlooked in the heat of the moment. Hope this helps!