This is a guide to installing node js on a Ubuntu machine. You can keep multiple versions of node simultaneously and switch between them as per the requirement.
Follow the below steps for installation :
Run the command ensuring your system is up to date.
sudo apt update
To install the latest stable version, run the command
sudo snap install node --classic
or Visit the Official Snap website to see the list of available versions.
To confirm the installed version of node, run the command
node -v
In case you wish to have more than one version of node installed. Run the command
nvm install v19.9.0
Here v19.9.0 is used as an example and can be replaced by a version of your choice!
To see all the available versions, use the command
nvm list-remote
To see the list of node versions that are installed on your pc, run the command
nvm ls
A similar result to the below image will appear.
To switch between the versions of node, run the command
nvm use v19.9.0
Here v19.9.0 can be replaced with any other version of node that is installed on the system.
Thanks for reading this. I hope this was helpful. Any comments or reactions will be wholeheartedly appreciated.
Ok, so before you run "nvm install" you should first install nvm. And if you are running nvm on your system, you really don't need to run this "sudo snap install node --classic"