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.sh
Take 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 | bash
This will install theĀ nvm
Ā script to your user account. To use it, you must first source yourĀ .bashrc
Ā file:
source ~/.bashrc
Now, you can ask NVM which versions of Node are available:
nvm list-remote
Output
. . .
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.0
Install by typing the version
nvm install v16.0.2
We can also use different version as well
nvm list
nvm install v16.0.0
switch the version
nvm use v16.0.0
I hope this guide helps you.
Ā
Ā