How to set up Node JS with Express and Welcome to Express

I am very new to node js, you can say at beginner level. But i wish to share, my learning in node js. Today i run node js Hello world! App. So, i am going to demonstrate  the Hello World! example in node js with full steps to set up.

In next node js blog, i will share node js with database connection with an working example.

Please write in comments, if i wrote anything wrong here. I will appreciate if i will learn from you guys.

To start with Node JS, you should have working knowledge of HTML,CSS and JavaScript. Node JS can add extra point in any Front end developer resume.

So, lets start setting up Node JS environment . First, you need to install node js package on your system. If you are not sure about this then you can check whether you have installed or not node js and npm. You can check by using this command –

node - v

this will give you nodejs version you are using

npm -v

this will give npm version you are using.

If you starting from scrtach then you should visit this article – How to install node js pacakage on windows

Now, after these steps, You have node js and npm installed on your machine to start with node js.

Now, we will install Express. Express is a node js web application framework. It organize your web app into a MVC architecture on the server side.  ‘

Write below command in folder where you want to set up your node js web application –

npm install -g express

nodejs-1

This will install some core functionality into our node installation and we can use it anywhere globally into our code. We need to install express generator as well. Installing the express generator is very easy, just write down below command in your console –

npm install -g express-generator

 

nodejs-2

Now, we will create  our express project by using below command –

express nodetest

(Please note – nodetest is app name)

nodejs-3

Now, we will instal the npm dependencoes in the nodetest folder –

npm insatll

nodejs-4

Now, our full functional wep app is ready to run. But, lets do some preparation for database. Lets create a folder to store our mongo or mysql db data. We will not use this folder for now.

\nodetest\mkdir data

Lets start our web server –

npm start

nodejs-5

Ya, it’s working. Open the link http://localhost:3000/ in the browser. You will see Welcome to Express Page.

We are running now, Node js web server with express engine and jade html preprocessor installed. Next, we will play with the code and will write a small app. Thanks for reading and commenting. .:)

 

Leave a Reply