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.
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.
Run the NodeJs Installer:
After downloading the node.js installer, run that file and then it will be going to show you following window:
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.
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.
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.
Create Hello World Application in NodeJs:
console.log(“Node installed successfully”);