Installing Node on ubuntu Using the Node Version Manager

Using Node Js we can run javascript from outside browser. With the help of node js we can create backend application using javascript.
In this article i am going to show you how to download and install node js in ubuntu machine step by step.
There are different ways to install node js on ubuntu machine. The simplest way to install using commandÂ
apt install nodejs
but the disadvange of this command is it install old version of node js. so to install latest version we are going to use nvm step by step.
Prerequisites
This guide assumes that you are using Ubuntu 20.04. Before you begin, you should have a non-root user account with sudo privileges set up on your system.
Installing Node Using the Node Version Manager
To install NVM on your Ubuntu 20.04 machine, visit the projectâs GitHub page. Copy the curl command from the README file that displays on the main page. This will get you the most recent version of the installation script.
Before piping the command through to bash, it is always a good idea to audit the script to make sure it isnât doing anything you donât agree with. You can do that by removing the | bash segment at the end of the curl command:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.shTake a look and make sure you are comfortable with the changes it is making. When you are satisfied, run the command again with | bash appended at the end. The URL you use will change depending on the latest version of nvm, but as of right now, the script can be downloaded and executed by typing:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bashThis will install the nvm script to your user account. To use it, you must first source your .bashrc file:
source ~/.bashrcNow, you can ask NVM which versions of Node are available:
nvm list-remoteOutput
. . .
v14.16.0 (LTS: Fermium)
v14.16.1 (LTS: Fermium)
v14.17.0 (LTS: Fermium)
v14.17.1 (LTS: Fermium)
v14.17.2 (LTS: Fermium)
v14.17.3 (LTS: Fermium)
v14.17.4 (Latest LTS: Fermium)
v15.0.0
v15.0.1
v15.1.0
v15.2.0
v15.2.1
v15.3.0
v15.4.0
v15.5.0
v15.5.1
v15.6.0
v15.7.0
v15.8.0
v15.9.0
v15.10.0
v15.11.0
v15.12.0
v15.13.0
v15.14.0
v16.0.0
v16.1.0
v16.2.0Install by typing the version
nvm install v16.0.2We can also use different version as well
nvm listnvm install v16.0.0switch the version
nvm use v16.0.0
I hope this guide helps you.
Â
Â

