How to install Node JS and NPM on your computer: Easy guide 2021

Today we will learn about how to install node js and npm, So friends let’s get started.

Node.js is the open-source and the best cross-platform JavaScript runtime environment. A Node. js app runs in a single process, rather than starting a new thread for each request. When Node.js performs an I/O operation, such as reading from the network or accessing a database or accessing a filesystem, rather than blocking the thread and wasting CPU cycles waiting for the response, Node.js will resume the operations when the response is received.

How to install Node JS and NPM on mac os

There are two types of Node.js releases: Current. LTS and long-term support (LTS)

Install Node JS Using Pkg Installar

Get download Node.js pkg installer from Node js official website. Node JS V-14 direct link is also available in blow button.

  • Then open this pkg installer with default installer.
  • Then follow the instruction till completion
  • After installation gets complete then close the window and then check Node js and npm version using command line.
node -v
npm -v

Install Node JS Using Homebrew

Homebrew is a package manager for mac os. it’s made like very easier you can install any package in a single straight forward command.

  • If homebrew is not installed then install in just single command
  • Then in just single command install node js and npm
brew update
brew install node

By default it will install latest version if you want to use eairler version then downgrade on that version.

Install Node JS Using NVM

 NVM (Node version Manager) that allows you to manage the versions of Node.js that you’ve got installed locally. you can switch on any version of node very easy.

Download the nvm install script via cURL:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash
  • check nvm is installed properly or not
nvm --version

Then install the node version that you want.

  • For latest version use
nvm isntall node
  • For specific version first check available versions
nvm ls-remote
  • Then install specific one
nvm install 14.15.6

How to install Node JS and NPM on Windows

Go to the official site of Node.js and get select Windows installer you will get the latest version of node js MSI or executable file on windows.

  • Then double click on the MSI file.
  • It will open an installation window then follow the instructions no need to change anything.

After installation complete open a command prompt and verify the node version

node -v
npm -v

How to install Node JS and NPM on Ubuntu

Install Node JS Using Default Repository

Ubuntu default repository contains default and stable verison of node for consistant behaviour.

  • To get install default node version. first get update default repository
sudo apt update
sudo apt install nodejs
sudo apt isntall npm
  • Check version
node -v
npm -v

Install Node JS Using NVM

 NVM (Node version Manager) that allows you to manage the versions of Node.js that you’ve got installed locally. you can switch on any version of node very easy.

Download the nvm install script via cURL:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash
  • check nvm is installed properly or not
nvm --version

Then install the node version that you want.

  • For latest version use
nvm isntall node
  • For specific version first check available versions
nvm ls-remote
  • Then install specific one
nvm install 14.15.6

Install Node JS using Binary

  • Download Node js binary from offical download page.
  • Copy the binary archived file to a directory where you want to install NodeJS. and the provide write access to the directory using “chmod”
sudo chmod -R 755 <direcoty-path>
  • Then extract the binary file in the directory
tar xf node-*.tar.xz
  • Then setup system path for node js
export NODEJS_HOME=/<installation-dir>
export PATH=$NODEJS_HOME:$PATH
  • This is for temporary for perment solution just add these variable in “bashrc”
vi ~/.bashrc
  • Add these variable in file.
export NODEJS_HOME=/<installation-dir>
export PATH=$NODEJS_HOME:$PATH

I hope you have successfully installed Node JS and npm. keep visiting our blog for more tech and other daily posts. Please give your valuable feedback in the comment box.

Leave a Comment

Share via
Copy link