Here we are going to learn about Node.js and its benefits.

What is Node.js and what are its benefits

NodeJS is a server-side platform like C++, Java, Python, Ruby on Rails, etc which is built on Google Chrome’s JavaScript Engine called(V8 Engine).

So what is a V8 Engine? v8 engine takes the javascript code that runs on the browser and it converts the script into machine code which other Javascript engines don’t do
and it is written in c++

It can be used to run outside the browser as well. For example, you can make Desktop applications using it.

It is Open Source, Completely free, used by thousands of developer around the world.

It can be used with MySQL, MongoDB and many other database engines.

Benefits of NodeJS.

Non Blocking Thread Execution(Asynchronous)

A node-based server never waits for an API to return the data.
For example, if there are series of API calls on the stack and if one request takes time for the response, the other request doesn’t wait.
The server moves to the next request and the notification mechanism of Event of NodeJS helps the server to get a response from the previous API call.
So simply NodeJS is faster

Cross Platform

So with NodeJS, you can make cross-platform applications. For example, if you take adobe products, they can run on both Windows and Macintosh Operating Systems.
So basically you create a common code and make it work for other operating systems

Compilation Time

Object-Oriented Programming Languages like c#, Java takes more than 30 seconds to compile the code. NodeJS compilation is very fast and takes very little time

Packages

There are more than 6 hundred thousand packages available on the node community.

JavaScript

Javascript itself a benefit. If you are a developer who knows Javascript, then learning NodeJS is very much easy for you.
So for Frontends like React or Angular and for Backend, you can use Javascript.

And there are so many benefits there for NodeJS.

Now lets move to the Requirements

Requirements to run and edit NodeJS projects on the systems

NodeJS application

You can download the NodeJS from here. The installation is very easy and it will not require any extra setup and it’s straightforward.

NodeJS
Download Nodejs

Editor

Nodejs need an editor to work on the code. We choose Visual Studio Code and you can download it from here. VS Code has many extensions that make us develop the application very easily.

Download Visual Studio Code
Download Visual Studio Code

Create First Nodejs Project

Once we installed Nodejs and Visual Studio Code, we need to check whether the Nodejs is properly installed on our system. To do that, open Terminal from Visual Studio Code or Command Prompt from your desktop and type the following command

Open New Terminal on Visual Studio Code
Open New Terminal on Visual Studio Code

On Terminal, type node -v. This will show the installed version of node. If it shows the Node version which means you have successfully installed the Nodejs.

Installed NodeJS Version
Installed Node Version

You may need to add some extensions to make your project fast and looks good.

Prettier – Code Formatter

Prettier - Code Formatter - NodeJS
Prettier – Code Formatter

This will format your code to make it more readable.

Bracket Pair Colorizer

Bracket Pair Colorizer - NodeJS
Bracket Pair Colorizer

With this extension, you can easily identify the start and end of a function.

Now go to Explorer on Visual Studio and start to create the Node application

Go to File -> Open Folder and create a Folder named nodejs on your local disk(Folder where you are going to store your files of Node application).

Once on the folder, now open Terminal on Visual Studio Code, then type

node init

This will initialize the node application. You need to enter some informations.

package name: techussain
version: (Hit enter)
description: (Give some Description about your application or simply hit enter)
entry point: (Hit enter) //By default index.js
test command: (Hit enter)
git repository: (Hit enter) //If you use git
keywords: (Hit enter) //About your application
author: (Hit enter) //Author of the Application
license: (Hit enter)

Is this OK? (yes) (Hit enter)

Once you done this steps you can see the package.json on the explorer.

package.json
package.json

Now we create the new file by clicking New File from explorer and name it as index.js.

On index.js type the following

console.log("Welcome to Techussain")
Create the first project
Create the first project

To run the file, simply go to the Terminal and type the following command

node index.js
Output

Now you can see “Welcome to Techussain” on the console.

But we need to start the full project using npm start command. To do that we need install some required packages.

In the next lecture I will show on how to install the required the packages and what are they.

Simple way to create asp.net repeater pagination control without using Sessions or Stored Procedure
Top 5 new features that have come in hand with Windows 11

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.