title: Deploying node js app to Heroku
body: <p>I've searched numerous stackoverflow q/a's and still can't seem to solve this. I'm trying to deploy my node js app to Heroku, and keep getting errors. I can run it on my local just fine.</p>
  
  <p><strong>Error:</strong></p>
  
  <pre><code>2014-10-17T13:47:11.174606+00:00 heroku[web.1]: State changed from crashed to starting
  2014-10-17T13:47:13.312806+00:00 heroku[web.1]: Starting process with command `node index.js`
  2014-10-17T13:47:14.494495+00:00 app[web.1]: module.js:340
  2014-10-17T13:47:14.493848+00:00 app[web.1]: 
  2014-10-17T13:47:14.504444+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:338:15)
  2014-10-17T13:47:14.504440+00:00 app[web.1]: Error: Cannot find module '/app/index.js'
  2014-10-17T13:47:14.494889+00:00 app[web.1]:     throw err;
  2014-10-17T13:47:14.495090+00:00 app[web.1]:           ^
  2014-10-17T13:47:14.504450+00:00 app[web.1]:     at node.js:906:3
  2014-10-17T13:47:14.504449+00:00 app[web.1]:     at startup (node.js:119:16)
  2014-10-17T13:47:14.504447+00:00 app[web.1]:     at Function.Module.runMain (module.js:497:10)
  2014-10-17T13:47:14.504446+00:00 app[web.1]:     at Function.Module._load (module.js:280:25)
  2014-10-17T13:47:15.551015+00:00 heroku[web.1]: State changed from crashed to starting
  2014-10-17T13:47:15.550391+00:00 heroku[web.1]: State changed from starting to crashed
  2014-10-17T13:47:15.538661+00:00 heroku[web.1]: Process exited with status 8
  2014-10-17T13:47:18.391309+00:00 heroku[web.1]: Starting process with command `node index.js`
  2014-10-17T13:47:19.331140+00:00 app[web.1]:           ^
  2014-10-17T13:47:19.333015+00:00 app[web.1]: Error: Cannot find module '/app/index.js'
  2014-10-17T13:47:19.333019+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:338:15)
  2014-10-17T13:47:19.330847+00:00 app[web.1]: module.js:340
  2014-10-17T13:47:19.330979+00:00 app[web.1]:     throw err;
  2014-10-17T13:47:19.333020+00:00 app[web.1]:     at Function.Module._load (module.js:280:25)
  2014-10-17T13:47:19.333021+00:00 app[web.1]:     at Function.Module.runMain (module.js:497:10)
  2014-10-17T13:47:19.333023+00:00 app[web.1]:     at startup (node.js:119:16)
  2014-10-17T13:47:19.333024+00:00 app[web.1]:     at node.js:906:3
  2014-10-17T13:47:19.330240+00:00 app[web.1]: 
  2014-10-17T13:47:20.165015+00:00 heroku[web.1]: Process exited with status 8
  2014-10-17T13:47:20.182699+00:00 heroku[web.1]: State changed from starting to crashe
  </code></pre>
  
  <p><strong>My app.js file:</strong></p>
  
  <pre><code>var express = require('express');
  var path = require('path');
  var favicon = require('serve-favicon');
  var logger = require('morgan');
  var cookieParser = require('cookie-parser');
  var bodyParser = require('body-parser');
  
  var routes = require('./routes/index');
  var users = require('./routes/users');
  
  var app = express();
  
  // view engine setup
  app.set('views', path.join(__dirname, 'views'));
  app.set('view engine', 'ejs');
  
  // uncomment after placing your favicon in /public
  //app.use(favicon(__dirname + '/public/favicon.ico'));
  app.use(logger('dev'));
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(cookieParser());
  app.use(express.static(path.join(__dirname, 'public')));
  
  app.use('/', routes);
  app.use('/users', users);
  
  // catch 404 and forward to error handler
  app.use(function(req, res, next) {
      var err = new Error('Not Found');
      err.status = 404;
      next(err);
  });
  
  app.get('/', function(req, res) {
    res.render('index', { title: 'The index page!' })
  });
  
  // error handlers
  
  // development error handler
  // will print stacktrace
  if (app.get('env') === 'development') {
      app.use(function(err, req, res, next) {
          res.status(err.status || 500);
          res.render('error', {
              message: err.message,
              error: err
          });
      });
  }
  
  // production error handler
  // no stacktraces leaked to user
  app.use(function(err, req, res, next) {
      res.status(err.status || 500);
      res.render('error', {
          message: err.message,
          error: {}
      });
  });
  
  
  module.exports = app;
  </code></pre>
  
  <p><strong>my route/index.js file:</strong></p>
  
  <pre><code>var express = require('express');
  var router = express.Router();
  
  
  /* GET home page. */
  router.get('/', function(req, res) {
      res.render('index', { title: 'Index' });
  });
  
  module.exports = router;
  </code></pre>
  
  <p>Any help is <em>greatly</em> appreciated</p>