Node.js — Install Express

Image Source
Assuming you have already installed Node.js

First, use terminal to create a directory to hold your application.

mkdir firstapp
cd firstapp

Use the npm init command to create package.json file that contains application’s information.

npm init

And then this command will prompts several questions about application, such as application name, version number…, etc.

For now, you can just press enter to use default value.

Questions about application.

Install Express in your directory and save it in the package.json’s dependencies list.

npm install express --save

Create a file called index.js and add some code below :

var express = require('express');
var app = express();

app.get('/', function (req, res) {
res.send('Hello World');


Use npm start command to run your code, than open the link localhost:3000/ in browser.

npm start

Now you can see your first app in the screen!