Skip to content
Advertisement

Express Node.js doesn’t work

I installed express 4 along with node.js,npm and express-generator on my ubuntu 12.04 and created an app using the following commands:

express test --hogan -c less
cd test && npm install
node app.js

Now what I should get is “Express server running on port 3000” but instead the command simply executes and doesn’t leave any message or error. So I have no idea of which port express is running on or whether or not it is running at all. So does anyone know what’s going wrong in it? Thanks in advance.

Advertisement

Answer

The new express-generator does not add the app.listen statement in the auto-generated app.js file. It could be a bug? What you can do is add a statement like

app.listen(3000, function () {
  console.log("express has started on port 3000");
});

This will instruct express to listen on port 3000 and print out a helpful message on the console as well.

Advertisement