Introduction To NPM And Node.js

What are NPM and NodeJS?

NPM stands for Node Package Manager.

Today there are so many JavaScript frameworks available in the market like Angular, Knockout, jQuery etc. Hence, to add these libraries into our web project, we download that JavaScript framework from the respective web site and add them into the project.

It would be great, if we could have a central node, where we can get any JavaScript framework. This is achievable , using NPM.

NPM is a centralized area, which connects to the various JavaScript frameworks available in the market.


Hence, to use NPM, you need to install the Node.js package from

Once you have installed the node, it gives a small command prompt, as shown below.

Open the command prompt and it looks, as shown below.

If we want to install jQuery in your project, then open the project folder location in Node.js command prompt and perform the npm install command.

If you want to install Angular, you need to perform another NPM command.

When you need more and more JavaScript frameworks in your project, it is a bit of a tedious task to go and install one by one.

There is a solution .

We need to create a file named package .JSON file in the folder, where you want to install the necessary JavaScript frameworks..

If you are new to JSON, it's better have a look at the articles related to JSON in

Create a package .JSON file with the following details.

The first two parameters are versions, the name is the version and the name of your project. You can give any version and name here.

devDependencies is the parameter, where we specify what JavaScript frameworks we need in our project.

For demo purposes, I have added Angular and jQuery.

Open the node command prompt and run NPM install.

Now, if we run npm install command, it checks for a file named “package. json” and it installs JavaScript frameworks mentioned in the devDependencies key in JSON file.

Since we have mentioned Angular and jQuery, 2 frameworks will be downloaded.

That’s it… You learned how to use npm.

Now, let’s understand what  Node.JS is

Node.js is JavaScript runtime, which is built on Chrome's V8 JavaScript Engine.

Basically, if we want to run a JavaScript code and we put this script inside HTML page and run this in a Browser Node.JS helps us to run JavaScript code outside the Browser.

Let me explain this with an example.

Create a JavaScript file named Hello.js inside a folder named Hello.

Let’s have a code like console.log (“Hello World from Node.js”) inside Hello.js

You ran a JavaScript code outside the Browser.

I hope, you all got a basic understanding about NPM and Node.js.

Ebook Download
View all
View all