How to install Nodejs latest version in ubuntu 20.04.2
When you install nodejs in ubuntu by default it install the node from apt repo where the latest version at the time of writing this article is v10.19.0.
But the latest version of node is v14.16.1 so how to install this? Don’t worry here i am going to give you solution about that.
Step->1
The thing is you can install nodejs from Node source PPA but i am going to show you how you can install by Node version manager that is NVM.So first we need to install nvm in ubuntu so write the command given below.
sudo apt-get update
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
source ~/.bashrc
Step->2
Now the nvm is successfully installed or not just check it by “nvm — version” if it shows you the version then everything is fine.Now we have installed nvm for checking node versions present just type the command given below.
nvm list-remote
and you will be get following output.
Step->3
In this step you need to install latest version of node from nvm so write the command given below.
nvm install v14.16.1 ( replace the version according to your requirement)
Step->4
Now if you will check node version you will not get what you wanted to see.Because you have downloaded two versions of node in which the default one is what it’s showing you so for making your latest node default and removing older one type following command in your terminal.
nvm alias default 14.16.1
you will get output as given below.
now if you will check “node -v” you will get what you want to see.
But we did not removed previous version that was 10.19.0 so removing that version write the command given below.
sudo apt remove nodejs
sudo apt get update