Node.js is a server side framework that provides a platform for backend runtime environment used for executing JavaScript code anywhere but on the browser. It uses JavaScript interpreter for executing code on the node server. It has been developed on Google Chrome browser’s V8 engine. 

This framework is best tool to code web applications where you require user to input data like online video streaming portals, web forms based applications, and other data intensive applications.

Node.js is open source and can be downloaded from here

NPM or Node Package Manager consists of a repository for Node.js along with CLI (command line interface). 

The following are the basic commands used in NPM to be used when getting started with node.js. 

-v : command used on mac to check whether node.js has been previously installed
on the system
-version can be used to check the version of the node.js framework installed. 
install <name_of_module> can be used to install several packages
available in NPM. 
var pkg-name
= require(name_of_module)

There are several packages/modules in NPM which can be installed to use the required functions in a js script.  

Example- installing node.js package

‘express’ is one such module and  is a web framework commonly used for its robustness and minimalist coding. It can be installed by using the following command on the command line:

npm install express

In the js script where you need the functions of ‘express’ module, you use the following command to use the functions of the express package in a JavaScript file. 

var pkg1 = require(‘express’)

A test suite can be executed after installing all the modules using the following command:

npm test

NPM command is used for initiating the node.js environment. Node.js apps can be executed on a localhost server. 

A prerequisite of package.json file is also required to develop a web project. 

npm i:  this command is used to install all the modules from directories inside the NPM. 

The Node.js server also makes your web app available to serve HTTP requests. It provides the interaction between users and your application. Creating and starting a server is an easy task using the inbuilt http module.

Be First to Comment

Leave a Reply

Your email address will not be published.