Why Node.Js? install express,Mongo DB and Jade

Hey Guys,

In this tutorial I want to show you how we can convert Node.Js to a web-server or even more. To do this conversion you need to install express, and also you need to do a few things:

run you command prompt and follow the steps:

  1. Create a directory for Node.js project

E:/mkdir node

2. now you need to install express, please use this command:

E:\node>npm install -g express-generator

3. Create a simple project in your node directly that you created in step 1

E:\node>express nodetest1

4. if you go to that folder you can see a few files and folders are added, this is simple project which is created for us and we want o change some of the configurations. if you open the node folder you can see the package.json, this json file contains list of dependency packages that are needed for this project. if you open the file in any text editor you can see something like :

“name”: “nodetest1”,
“version”: “0.0.0”,
“private”: true,
“scripts”: {
“start”: “node ./bin/www”
“dependencies”: {
“body-parser”: “~1.12.4”,
“cookie-parser”: “~1.3.5”,
“debug”: “~2.2.0”,
“express”: “~4.12.4”,
“jade”: “~1.9.2”,
“morgan”: “~1.5.3”,
“serve-favicon”: “~2.2.1”

we only need to add a few items to the dependencies, as I want to show you how to use mongoDB in node js, so we need to add mongoDB dependency to this file. Please change the dependencies section like this:

“dependencies”: {
“body-parser”: “~1.12.4”,
“cookie-parser”: “~1.3.5”,
“debug”: “~2.2.0”,
“express”: “~4.12.4”,
“jade”: “~1.9.2”,
“morgan”: “~1.5.3”,
“serve-favicon”: “~2.2.1”,
“mongodb”: “~2.0.33”,
“monk”: “~1.0.1”

5. Next step is to install all dependencies that are mentioned in the package.json. run the command prompt and execute the below command:

E:\node\nodetest1>npm install

6.Once you install everything, you need to create a data directity in node folder, the reason that we need to create data folder is that we want to user mongoDB and we already installed dependency for mongoDB, so without data folder you will face with error 🙂 , so easily run this command in command prompt:

E:\node\nodetest1>mkdir data

7. Now everything is ready to run the Node.js, to run Node.js  you can execute the below command:

 E:\node\nodetest1>npm start

8: To see the result of what have done in this tutorial type this address in browser:


Maybe you are still a bit confused about node.js, but do not be please, it is very normal specially for those programmers that are not familiar with these kind of coding and environments. we just started and you need go through the whole training to understand what exactly is happening. 🙂

Bye bye

Categories: Uncategorized

Tags: ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: