DEV Community

Discussion on: Causes of Heroku H10-App Crashed Error And How To Solve Them

Collapse
 
urosran profile image
Uros Randelovic • Edited

Up until recently I was able to deploy development build to Heroku and since couple of days ago even out-of-the-box npx create-react-app would fail with H10 code - solution was to ofc deploy the production build like below:

npm install serve --s

"scripts": {
"dev": "react-scripts start",
"start": "serve -s build",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"heroku-postbuild": "npm run build"
}

Collapse
 
radkin profile image
Noel Miller

Thanks. You saved me a lot of time and trouble.

Collapse
 
joejcox profile image
Joe Cox

Hero!!! Thank you!

Collapse
 
ezzaffa88 profile image
SOFIEN

Really thank you Very Much you saved my Wasted Time with installing serve and calling it on start script

Collapse
 
haimbuchbut profile image
Haim Buchbut

Thanks. It solved my problem on Heroku, but I can't run my app locally.
After installing serve and modifying package.json, when I run npm start - serve says the app is available on port 5000 but I'm getting 404 page there. (it doesn't work also on port 3000 which was the one that I used so far).
Any ideas why?

Collapse
 
urosran profile image
Uros Randelovic • Edited

Hi Haim,

If you run yarn start/npm start now it points to 'serve -s build' instead of 'react-scripts start'.

Make sure you've added below:

"dev": "react-scripts start",
"start": "serve -s build",

and to run your app locally do npm run dev not npm start

Thread Thread
 
haimbuchbut profile image
Haim Buchbut

Thanks. It didn't work with "npm dev" (I got that "dev" is invalid command), but it did work with "npm run dev".

Thread Thread
 
lawrence_eagles profile image
Lawrence Eagles • Edited

I am glad to hear this worked for you.
Just a side note:
commands like npm start can work directly because they are default commands from npm but custom commands like dev set by the user would only work with the run command. npm run dev. I hope this clears things up.

Collapse
 
lucianonahuel4528 profile image
Lucianonahuel4528

Thanks my brother....
Greetings from Argentina Corrientes

Collapse
 
danielfruitspec profile image
DanielFruitSpec

Finally! it worked!! Thank you so much!!!!

Collapse
 
marlonx19 profile image
Marlon Englemam

I have no idea why, but install serve --s solved the issue!!! Why is that??
I have many other older react apps running normally on heroku without needing to install serve --s

Collapse
 
hickeymonster profile image
Emmanuel Okwuzi

Thanks a lot!

Collapse
 
starkky07 profile image
Kishan Sahu

Thank you very much. Now it serves like a charm.

Collapse
 
sayanta2702 profile image
Sayanta Bhattacharje

This worked ...Thanks for saving a day's work

Collapse
 
ch1zo profile image
chizo nwazuo

Thank you sooo much! This sure saved me a lot of frustration. Was wondering if you could give a bit of insight about how you figured out this solution

Collapse
 
urosran profile image
Uros Randelovic

If you look at the logs it says 'starting development server' - given that if we deploy something to heroku we want it to be prod environment for variety of reasons (stackoverflow.com/questions/481511...). I looked at the versions of react and it so happened that react itself was upped a version 2-3 days prior to my attempt to deploy so I realized that whatever heroku was doing before to serve the build server obv somehow broke so I decided to change it to prod build (which I should have done from the get go but never cared as I just wanted to send the app to friends)

Collapse
 
raqgoth profile image
Raquel Gothardt

Thank you soooo much!!!! this worked!!! ater 2 days of being stucked!!!!

Collapse
 
nelsong1997 profile image
Gabe N

I spent many hours troubleshooting and this ended up working. Thank you!!

Collapse
 
moidhasanbeig profile image
Moid Hasan Beig

The same occurred with me. Thanks for this solution.

Collapse
 
lawrence_eagles profile image
Lawrence Eagles

I am glad this helped you resolve your issue.

Collapse
 
uzairjan profile image
Uzair Khan

Thanks dude.

Collapse
 
sagarkharabe profile image
Sagar Kharabe

Same happened to me. Do you know why this is happening?

Collapse
 
urosran profile image
Uros Randelovic

We can only speculate, React was updated on March 20th and around then it stopped working so I am guessing there is something that is happening with webpack or whatever was successfully serving our apps.

Collapse
 
marlieer profile image
marlieer

Thank you!!! This solved it

Collapse
 
jdrichardstech profile image
JD Richards

This was a lifesaver. Thanks!

Collapse
 
davidgoodson profile image
Buyinza David

Wow.. this worked like a charm.

Collapse
 
coltonkaiser profile image
Colton Kaiser

This worked!!

Collapse
 
marcosaponaro profile image
marcosaponaro • Edited

Thanks a lot, now deploy on Heroku is working! But I've found another issue. Changing from npm start to serve -s build the local solution (npm run dev) is the correct one but the one on Heroku is not the same (is something like the first beninning project template). Why this difference? I've tried with a npm run build command but no difference. Thank you

Collapse
 
chandanxp profile image
Chandan

24-Aug-2020 : I tried this fix and this worked for me ,
1.) "npm install serve --s" in my terminal

"scripts": {
"dev": "react-scripts start",
"start": "serve -s build",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"heroku-postbuild": "npm run build"
}

2.) copied the above code("scripts") in place of my previous code "scripts" in my package.json file
3.) git commit -am "new update"
4.) git push heroku master

and Boom I found my wesite on herokuapp
thank you very much

Collapse
 
saimaar profile image
Saima Rahman

This worked like magic! Thank you so much!

Collapse
 
ajgcph2019 profile image
ajgcph2019

Thank you.This worked for me

Collapse
 
guilhermebodart profile image
Guilherme-Bodart

Pros BR's de plantão, isso aqui ainda funciona, fiz aqui no meu e meu deploy deu certo, caso esteja assim no seu,
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
}
use o npm install serve --s e altere igual ao comentário a cima.

THAT STILL WORKS ON 30/01/2020

Collapse
 
tjombell profile image
Tjomb Bell

It works for me thank you very much !!!

Collapse
 
moazamdev profile image
Moazam Ali

Thank you for providing this steps, It also worked for me

Collapse
 
dalisc profile image
Dalis Chan

THANK YOU!!! i created this account just to thank you because I had so so much trouble deploying. Build was fine but after build when heroku tried to run start, I ran into so many H10 and H12 errors and the app can't even display a static page.

Your solution worked PERFECTLY!

Collapse
 
rohit_rambade profile image
Rohit Rambade

Thank You !!!

Collapse
 
monatyagi profile image
MonaTyagi

It worked for me, thanks a lot !

Collapse
 
daleluce profile image
DaleLuce

Looks like i picked a bad time to attempt to deploy my first web app. Does this mean I need to run this line in my command module "npm install serve --s"

and then copy this into my package.json exactly as is?

"scripts": {
"dev": "react-scripts start",
"start": "serve -s build",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"heroku-postbuild": "npm run build"
}

I tried to do that and it didn't work when I went to update the master on heroku.
Thanks in advance...

Collapse
 
hickeymonster profile image
Emmanuel Okwuzi

Thanks for this it was helpful

Collapse
 
cmarshman profile image
Cory Marshman

As of May 23rd, 2020. This fix worked beautifully. I've never had any issues pushing to heroku until my most recent project. This was perhaps my 4th or 5th attempt to fix it and this work amazingly. Thanks DaleLuce

Thread Thread
 
efecollins profile image
Efosa Collins EVBOWE

Works like a charm

Collapse
 
hickeymonster profile image
Emmanuel Okwuzi

Thank you!. This worked!

Collapse
 
danielfruitspec profile image
DanielFruitSpec

yes!!! Thank you so much!! yes yes yes yes

Collapse
 
maskoul profile image
Mohamed Maskoul

@daleluce Thank you so much thank uuuu!! i spent all the day to fix this problem i tied so many solution on internet but only your solution worked!! i was give up but you saved me, i made the account now to thank you <3

Thread Thread
 
daleluce profile image
DaleLuce

Thanks for letting me know Mohamed! This made my day!

Collapse
 
hadarose profile image
Hadar Rosenman

Worked like a charm after 2 days of frustration! Thank you!!!

Thread Thread
 
jaytailor10 profile image
jaytailor10

I made this app without authentication and there was no problem deploying it on heroku but now I have added authentication to it and heroku is creating trouble. Looks like I am gonna stuck here for weeks.