application.js wont start but debug works

I am new to node.js and I want to get webserver running but I got this problem where trying to debug application by running node ./bin/www works perfectly but trying to launch it by node app.js dosen't do anything.

When i type out node app.js in terminal blank line appears like its loading something and dissapears in few seccods without any error or starting application.

The problem is that app.js is exporting an app object, not starting a server. If you look at the code for bin/www you'll see that it loads the app object and uses it to start a server.

#!/usr/bin/env node
var debug = require('debug')('tmp');
var app = require('../app');

app.set('port', process.env.PORT || 3000);

var server = app.listen(app.get('port'), function() {
  debug('Express server listening on port ' + server.address().port);
});

You need to either start the app using bin/www, or modify and move that code to the end of app.js if you don't want the separate start script.

If you want to see the debug messages, you need to add the DEBUG environment variable to your shell session. For development environments, you could do this automatically by placing it in your .bashrc file.

export DEBUG=express:*

Or if you do not want to do that, you can just do this:

DEBUG=express:* node ./bin/www

http://expressjs.com/guide.html#debugging-express