The application that the generator makes calls to ./bin/www , which includes app.js , and then starts listening to traffic.
app.js does not do this itself .
I think this is important to understand.
app.listen not called in app.js , but it is called in ./bin/www ... and that is why you get the result exit 0 . When you call app.js , not ./bin/www , it starts through the file, but since the command does not listen to traffic, the program ends normally ... i.e. having done nothing.
However, you have two options.
Option 1
If you have a ./bin/www file, you can run supervisor ./bin/www to get started.
Option 2
If you donβt have a ./bin/www file for any reason, you can edit the application file to look like this.
In the application list, replace
module.exports = app;
with this
app.set('port', process.env.PORT || 3000); var server = app.listen(app.get('port'), function() { debug('Express server listening on port ' + server.address().port); });
Important Note
While this editing will start listening to the application and you will no longer get exit 0 , I can not guarantee that the application will not crash with any other error if other files and directories are missing. For example, if the routes directory is missing, then ads requiring routes/index and routes/users will fail and other bad things will happen.
Matthew Bakaitis
source share