Friday, 2 June 2017

How to deploy to Heroku the right way?

I am trying to deploy my application to Heroku with Github, that is a NodeJS Application, but for some reason I am getting a

"Application Error: An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details."

I don't know what I did wrong. Here is my log:

    -----> Node.js app detected
-----> Creating runtime environment

       NPM_CONFIG_LOGLEVEL=error
       NPM_CONFIG_PRODUCTION=true
       NODE_VERBOSE=false
       NODE_ENV=production
       NODE_MODULES_CACHE=true
-----> Installing binaries
       engines.node (package.json):  6.10.3
       engines.npm (package.json):   unspecified (use default)

       Downloading and installing node 6.10.3...
       Using default npm version: 3.10.10
-----> Restoring cache
       Loading 2 from cacheDirectories (default):
       - node_modules
       - bower_components (not cached - skipping)
-----> Building dependencies
       Installing node modules (package.json)
-----> Caching build
       Clearing previous node cache
       Saving 2 cacheDirectories (default):
       - node_modules
       - bower_components (nothing to cache)
-----> Build succeeded!
-----> Discovering process types
       Procfile declares types -> web
-----> Compressing...
       Done: 18.4M
-----> Launching...
       Released v24 

Here is my package.json file.

    {
  "name": "chat",
  "version": "0.0.0",

  "scripts": {
    "start": "node ./lib/index.js",
    "test": "jasmine"
  },
  "engines": {
    "node": "6.10.3"
  },

  "repository": {
    "type": "git",
    "url": "git+https://github.com/****/*****.git"
  },


  "dependencies": {
    "express": "~4.13.1",
    "firebase": "^3.9.0",
    "request-promise": "^2.0.1",
    "socket.io": "^1.4.5"
  },
  "devDependencies": {
    "jasmine-sinon": "^0.4.0",
    "jscs": "^2.11.0",
    "proxyquire": "^1.7.4",
    "rewire": "^2.5.1",
    "sinon": "^1.17.3"
  }
}

index.js

    var express = require('express');
var app = express();
var path = require('path');
var http = require('http').Server(app);
var io = require('socket.io')(http);

var routes = require('./routes');
var chats = require('./chat');



app.use(express.static(path.join(__dirname, '../public')));

routes.load(app);
chats.load(io);



http.listen(process.env.PORT || 5000, function () {
    console.log('Express server listening on %d', process.env.PORT);
});



via Billy Jr.

No comments:

Post a Comment