Node.JS is an invaluable and prevalent platform available today as an open-source tool for developing applications, network tools, and much more. There are various versions available today, and while some might prefer the latest option, developers often rely on older versions. Today you will learn how to install Node.JS on Ubuntu, including other versions.
There are three different options available for you to install Node.js on Ubuntu 20.04
- Standard Ubuntu Repositories
This method is usually the ‘go-to’ option and among the easiest ways available. It should suffice for most of the time.
- NodeSource Repository
This method is suitable if you want to install a different version of Node.js than the one available by default. If you don’t want to use the version available in Ubuntu repositories, use this option. You will find different versions available in the list.
- Node Version Manager
Also known as the ‘NVM’ method, it allows you to install multiple Node.js versions on a single system. If you’re a developer, you would most likely prefer this option to work with different versions.
Using Ubuntu Repository
This is the easiest and quickest method available. All you need to do is run the following command:
● sudo apt update
● sudo apt install nodejs npm
You might have to verify the version. For that, use the command:
● nodejs –version
Installing npm Package
It’s usually a good idea to download and install npm. It is a Node.js package manager. For this, you can use apt to install the npm package. Run the following command:
● Sudo apt install npm
This will install the package and module you’re looking for to handle node.js.
Using Nodesource Repository
Nodesource is among the pioneers when it comes to Node support. Commonly it is known as the ‘APT’ repository, which contains various versions of Node.js available for you to install. If you have a specific version requirement, it might be the best option available.
- First, you would have to determine the version you want to install. After that, you need to move ahead with the command. You can use the following command in the terminal:
● curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash –
- Replace ‘setup_12.x’ with any other version, like if you want version 14, then write setup_14.x
This option won’t install node.js, but add the signing key and create an apt repository file for you. It will mostly prepare all of the resources for you. The option might also install NPM automatically to ensure you have a complete toolset.
Now, to install, you will have to initiate the following command:
● sudo apt install nodejs
This will install node.js, and then you can use the same command like the one in Ubuntu’s repository to check the version:
● node –version
Using The Node Version Manager (NVM) Method
As mentioned earlier, NVM allows you to manage and operate multiple Node.js versions on the system without any problem. You can install or uninstall any version. To get NVM, you have to visit the Github repository. From there, you can either get the ‘curl’ or ‘wget’ command to download the NVM.
Here are the two:
● curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
● wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
Once you do that, you’d have to close and restart the terminal to ensure that NVM is operating. You can also check the version by initiating the command:
● Nvm –version
Once you confirm, you can move on and get the list of the Node.js versions available for you with the following command:
● Nvm list-remote
To install the latest version, run the following command:
● nvm install node
If you want to install a different version, you will have the version name for the ascommand on the list. For instance, nvm install-lts is for Node.Js 12 LTS. You can also use the following command:
● Nvm install 12.18.0
Once you install the Node.JS, once again run the following command to check the version:
● node –version
To install other versions, you have to follow the same command and just type the installation command. It won’t overwrite the pre-existing node.js in your system. You will simply have other versions installed, as well.
If you want to check out the versions installed on your system, use:
● nvm ls
If you want to use a different version, then use the following command and the version name, for example:
● nvm use 14.4.0
To uninstall any version from your system, use the following command with version name:
● nvm uninstall 12.18.0
Check Ubuntu Update
Before you start installing Node.JS on your Ubuntu, make sure that you have the latest package. For that, initiate the following command:
● sudo apt -y update
Now you know how to install Node.JS on Ubuntu by using different repositories and options. Hopefully, it was sufficient for you and concise enough to follow through.
Signup Here For More Details: https://bit.ly/3mFerJn