Node Js – Installation

The latest NodeJS installations come with npm as the default package manager.

As show in the diagram :

  1. NodeJs provides the runtime environment and the core libraries and
  2. npm (Node Package Manager) helps us add libraries from external NPM registries.
    • The external registry may include a the open source NPM registry or a corporates own private registry.

 

1. Manual & NVM Installation

We can install NodeJS manually by using the OS specific installable versions or install it using a Package Manager.

 

Manual Installation

We can install NodeJS manually by downloading an installable version from its official website : 
https://nodejs.org/en/download/ 

This is easy and straight forward when we do not have to switch NodeJS versions frequently. But, switching to a different NodeJS version will need us to uninstall the old version and re-install the new version manually. 

Installation using Package Managers

If we install the NodeJS using its Package Managers, it makes the switch between different version easy. The Package Manager takes care of un-installing the old version and installing the new version.

The different Package Managers for different OS are available at the following official URL: 

https://nodejs.org/en/download/package-manager/

Note : Package Managers such as nvm (Node Version Manager) manage the NodeJS versions where as the npm (Node Package Manager) coming with NodeJS manages the projects built on NodeJS.

 

2. Steps to Install Manually on Windows

1. Download the Windows Installer from the nodejs.org web site. 
2. Specify the path during installation as shown below. The default path is : C:\Program Files\nodejs 

 

3. Verify NodeJS & NPM

Verify NodeJS

First verify that the Windows PATH environment variable contains the NodeJS installation path.

Then we should be able to run node command from any directory. Hence, create your folder for nodejs and run the following command to check the installed Nodejs version.

F:\nodejs\examples>node -v

v12.18.3


Again, the node is the command to run our Javascript files. If we create a simple test.js file as below:

//A simple console.log 
console.log('My First NodeJS Script !');

 

We should be able to run the script file as follows:

F:\nodejs\examples>node test.js
My First NodeJS Script !

 

Verify NPM

The NodeJS comes with npm as its default package manager. In order to verify npm, run the following command:

F:\nodejs>npm -v

v6.14.6