NodeJs

NodeJs Tutorial #02: Setting Up NodeJs Environment.

Setting Up node Js and npm run time environment, create Hello world application

In the previous knowledge bit, we have discussed that how the internet works and we have seen the difference between front-end and back-end and static and dynamic site. We have also given the introduction about Node.js and discussed why we should use node.js. Now in this node.js tutorial, We will look at Setting Up NodeJs environment and how we can create simple Hello World application with node.js.

Setting Up NodeJs:

The installation of the node.Js runtime is divided into three task, first we download node then we will see that how we can install node and in last we will verify that whether node installed successfully or not.

Installing NodeJs:

To install node.js on our machine go to official website of Node.Js (Link: https://nodejs.org/en/download/ ). Now you can notice we have a different version available, LTS which is recommended by many users and current Version which is basically Latest Version. We will download the one version which is recommended and stable. So download the version which is compatible with your machine, like if you are windows user then grab windows installer.

 

NodeJs Tutorial: Setting up NodeJs - Download Nodejs runtime for windows

Run the NodeJs Installer:

After downloading the node.js installer, run that file and then it will be going to show you following window:

 

NodeJs tutorial: install Nodejs runtime on windows

 

Click next, and then it will show you the screen of End-User License Agreement (EULA), accept the license agreement and click next.

Now it will ask you for the specific destination. Now provide the destination where you want to install and click next. After specified folder screen, it will show you custom setup screen. In that screen select npm package manager, it will install both Node and NPM at the same time.

 

How to install NodeJs runtime

Click next, and the setup wizard is now ready to install Node and npm. Now click on the install button, node.js is lightweight and will take your few seconds to install.

Verify that NodeJs installed properly:

Now let’s go ahead and verify that by running it from the terminal. Open Command Prompt and terminal depending upon the machine you are using.

Open Command prompt windows on 10, windows 8, windows 7

 

Now type node –v this is going to print the version of the node currently installed. In our case, it’s version v8.11.2. If we want to check npm version then we will do the same write npm -v in the terminal.

 

Check nodejs and npm version

Create Hello World Application in NodeJs:

Now to check if the node.js successfully installed or not, open the sublime text editor or any other editor that you are familiar with. Create a JavaScript file and type following one line of code:

console.log(“Node installed successfully”);

Now save that file in some directory and open your terminal, navigate to the folder where you save that JavaScript file. After navigating to that file type node and then file name. In our case, we have saved the file as hello.js, so I will write node hello.js in our terminal.

 

Create first Hello World Nodejs Application

You can notice in the above command prompt screen that we have got Node installed successfully when we run the JavaScript file.

Conclusion:

In this Node.js tutorial, we have seen the process of Setting Up NodeJs environment. Then, we have verified that whether our node package has installed successfully or not. And in last we have learned that how we can run simple JavaScript file in node.js

Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Most Popular

To Top