Introduction to Node JS
In this post we will learn about the basics of Node JS. This article explain the process of installing node js in your system and the basic thing you need to do to configure. You can also get an idea of testing the node js by using some piece of code. Some of you might have already tried this. This article is for the one who have never tried Node JS. I hope you will like it.
Today one of my colleague asked me “what is Node JS?”. I could manage with the definition. But it might have not helped him much. So I thought of creating an article and send him the link for his reference. Hereby I am dedicating this article to him.
What is Node JS?
To start with
To start with Node JS, you need to go to https://nodejs.org/ and click on install.
Figure 1: Download
Now a .msi file will be downloading in your system. Please run that once the downloading is over.
Figure 2: Installation
Figure 3: Installation Continue
Now I hope you have installed Node JS, So what is next? We need to test our node platform right?
Testing Node JS
To check whether our Node JS is working fine, We can create a “Hello World” program in two ways.
Directly type message in command window
Open your command window( Press Window key + R ), type cmd in the window. Now a window will be opened, you can type your commands over there.
Once you pointed out to your drive as shown in the image, type “node” and press enter. Now you can type anything in your console using console.log. Then You will get the output as shown in the above image.
Now you may be thinking why it returns an undefined error!. Am I right?
It is because of, normally Node JS will displays return value of each commands. As you all know console.log does not return anything. So it is displaying ‘undefined’.
Type the message in a js file and execute it in node
Create a js file manually ( To do so, open a notepad, type some content and save it with .js extension. That is all. )
I typed the content as “console.log(‘Sibeesh passion welcomes you to the world of Node’);”
Now you can execute that JS file as follows.
I hope you will like this article. Please share me your valuable thoughts and comments. Your feedback is always welcomed.
Thanks in advance. Happy coding!