Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 253
Abhishek Mhatre Avatar asked May 13 '14 17:05

Abhishek Mhatre


People also ask

Is ExpressJS still used 2021?

Express is currently, and for many years, the de-facto library in the Node. js ecosystem. When you are looking for any tutorial to learn Node, Express is presented and taught to people.

What is Express () in NodeJS?

Express is a node js web application framework that provides broad features for building web and mobile applications. It is used to build a single page, multipage, and hybrid web application. It's a layer built on the top of the Node js that helps manage servers and routes.

Is ExpressJS necessary for NodeJS?

Developers need to install ExpressJS along with NodeJS to use it. There is no need to install AngularJS on their computer system to use it. Used for developing server-side and networking applications. Used for building server-side applications on NodeJS.


1 Answers

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.

like image 57
Akshat Jiwan Sharma Avatar answered Sep 20 '22 10:09

Akshat Jiwan Sharma