Download Node JS and change version using NVM

On Ubuntu :

  • You can download using Ubuntu repository
--Check the repository available node version using command
sudo apt-cache show nodejs
--Install nodejs using below command
sudo apt install nodejs

All the steps are mentioned in below url

https://github.com/nodesource/distributions/blob/master/README.md

Node Version Manager (NVM)

Why NVM ?

  • Suppose you are core developer of Node Js who reviews code of many node js developers
  • All the different applications code that you review might note be running on the same exact version of Node JS.
  • So now you cannot re-install the Node Js everytime you encounter a new version so, NVM helps you to change the Node version as you please.

Description

  • There are many tools available on internet to manage node versions
  • We are going to use NVM in our case
  • Below is the link for documentation
    https://github.com/nvm-sh/nvm#installing-and-updating
  • Run below command to install nvm
----download using below command
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.1/install.sh | bash
----reload the bashrc
source ~/.bashrc
----List of node version
nvm list-remote
----Install a node version
nvm install v14.15.1
----List of installed node version installed on your system
nvm list
----Change the node version using nvm
nvm use v14.15.1
----Check node version
node -v
----Change Back to system version of nodejs
nvm use system

Leave a Comment