2
[34mℹ[39m [90m「wds」[39m: Project is running at http://localhost:47627/
2020-03-09T15:02:19.370628+00:00 app[web.1]: [34mℹ[39m [90m「wds」[39m: webpack output is served from /
2020-03-09T15:02:19.370747+00:00 app[web.1]: [34mℹ[39m [90m「wds」[39m: Content not from webpack is served from /app
2020-03-09T15:02:24.227741+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2020-03-09T15:02:24.227741+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-03-09T15:02:24.454880+00:00 heroku[web.1]: State changed from starting to crashed
2020-03-09T15:02:24.434525+00:00 heroku[web.1]: Process exited with status 137
    "heroku-dev": "npm i -dev",
    "wbuild": "webpack --mode production",
    "wstart": "webpack-dev-server --mode development --hot --open --port $PORT",
web: npm run heroku-dev && npm run wbuild && npm run wstart

I looked around the internet, but couldn't find anything

Qeole
  • 8,284
  • 1
  • 24
  • 52
Carter Nabors
  • 67
  • 1
  • 5

3 Answers3

3

I too faced the same issue. After debugging found that - I missed out to bind the app to 'process.env.PORT'

app.listen(process.env.PORT || 5000);
Dharman
  • 30,962
  • 25
  • 85
  • 135
2

https://devcenter.heroku.com/articles/app-json-schema

In your app.json you need a postdeploy script.

I assume this is your current Procfile:

web: npm run heroku-dev && npm run wbuild && npm run wstart

Change it to:

web: npm run wstart

Your postdeploy should say npm run heroku-dev && npm run wbuild


Second approach is to do it via package.json (no app.json needed).
It is working similarly see the docs here:

https://devcenter.heroku.com/articles/nodejs-support#customizing-the-build-process

"scripts": {
  "start": "webpack-dev-server --mode development --hot --open --port $PORT",
  "build": "npm i -dev && webpack --mode production",
  "heroku-postbuild": "npm build"
}

With Procfile being web: npm start


The problem you have is you are building your project each time when started and it is taking too long for it to bind to the $PORT. It should be build once at the very beginning after deployment.

Tin Nguyen
  • 5,250
  • 1
  • 12
  • 32
1

I do wath you say and I add a new config var on Heroku

key NODE_ENV

value production

like in the link:

https://github.com/christianalfoni/webpack-express-boilerplate/issues/53

It finally work!

Frotta
  • 11
  • 1