0

I am simply trying to deploy a very straight forward nodejs server and webpack application to heroku but i get the following error from Heroku:

2018-03-26T12:02:19.952603+00:00 app[web.1]: webpack: Compiled successfully.
2018-03-26T11:52:19.406889+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2018-03-26T11:52:19.406889+00:00 heroku[web.1]: Stopping process with SIGKILL
2018-03-26T11:52:19.486385+00:00 heroku[web.1]: Process exited with status 137
2018-03-26T11:52:19.497230+00:00 heroku[web.1]: State changed from starting to crashed

Seems like there is something wrong with the port but i am not sure what else i could do. Here is what my node looks like:

/* jshint esversion: 6 */

var express = require('express');
var path = require('path');
var serveStatic = require('serve-static');

app = express();

app.use(serveStatic(__dirname + "/dist"));

var port = process.env.PORT || 5000;

app.listen(port);

and my package.json:

{
  "name": "xxx",
  "version": "1.0.0",
  "description": "xxxx",
  "main": "index.html",
  "scripts": {
    "start": "npm run serve",
    "serve": "webpack-dev-server --colors --watch --inline --progress --content-base /src --config config/webpack.dev.js",
    "test:js": "eslint src/js/**",
    "test:scss": "stylelint src/scss/**/*.scss",
    "test": "npm run test:js && npm run test:scss",
    "build": "npm run build:dev",
    "build:dev": "ENV=dev webpack --config config/webpack.dev.js",
    "build:prod": "npm run clean && ENV=prod webpack --config config/webpack.prod.js",
    "clean": "rimraf -- dist",
    "clean:all": "rimraf -- node_modules dist"
  },
  "license": "UNLICENSED",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/xxx/xxxx.git"
  },
  "keywords": [
    "design",
    "site",
    "front-end"
  ],
  "author": "xxxx",
  "dependencies": {
   ...
  },
  "devDependencies": {
   ...
  }
}
0xtuytuy
  • 1,494
  • 6
  • 26
  • 51
  • Possible duplicate of [this post](https://stackoverflow.com/questions/15693192/heroku-node-js-error-web-process-failed-to-bind-to-port-within-60-seconds-of). – Hubert Mar 26 '18 at 12:04
  • @Hubert No, because I do have the line process.env.PORT || 5000 in my code. – 0xtuytuy Mar 26 '18 at 12:06
  • 1
    Take a look at https://stackoverflow.com/questions/41973338/hosting-a-production-react-app-built-with-wepback-on-heroku/41973881#41973881 and https://stackoverflow.com/questions/48531545/heroku-failed-at-the-build-script-but-heroku-local-web-is-fine/48538277#48538277 – Yoni Rabinovitch Mar 26 '18 at 13:29
  • @Rémi, are you ignoring the `node_modules` to git? – Daniel Mar 26 '18 at 14:56
  • @YoniRabinovitch this was my answer thank you ! add it as a message ill accept it ;) – 0xtuytuy Mar 26 '18 at 19:12
  • Possible duplicate of [Hosting a production React app built with Wepback on Heroku](https://stackoverflow.com/questions/41973338/hosting-a-production-react-app-built-with-wepback-on-heroku) – Yoni Rabinovitch Mar 27 '18 at 13:00

0 Answers0