Different option to install node.js on ubuntu

nodejs

node installation on ubuntu

In this document, we will discuss different options to install Node.js on Ubuntu.

Option 1: Install via NVM (Node Version Manager)

One way of installing Node.js on Ubuntu is by using NVM. Follow the steps below to install Node.js via NVM:

  1. Run the following command to download and install NVM:
$ curl -o- <https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh> | bash

  1. Once NVM is installed, run the following command to see the list of available Node.js versions:
$ nvm list-remote

  1. Choose the LTS (Long Term Support) version greater than 14 and install it using the following command:
$ nvm install <LTS version greater than 14>

Option 2: Install via apt-get

Another way of installing Node.js on Ubuntu is by using apt-get. Follow the steps below to install Node.js via apt-get:

  1. Update the apt package list:
$ sudo apt-get update

  1. Install Node.js using apt-get:
$ sudo apt-get install nodejs

  1. Verify that Node.js and npm (Node Package Manager) have been installed successfully:
$ node -v
$ npm -v

Option 3: Install via Node.js Website

Another way to install Node.js on Ubuntu is to download the installer from the official Node.js website. Follow the steps below to install Node.js via the website:

  1. Go to the Node.js website and download the LTS (Long Term Support) version for Ubuntu.
  2. Once the download is complete, navigate to the directory where the downloaded file is located and run the following command to extract the contents of the file:
$ tar -xvf <filename>.tar.gz

  1. Navigate to the extracted directory and run the following command to install Node.js:
$ sudo ./configure
$ sudo make
$ sudo make install

  1. Verify that Node.js and npm (Node Package Manager) have been installed successfully:
$ node -v
$ npm -v

Conclusion

We have discussed three options to install Node.js on Ubuntu. among them I personally feel that option 1 is more suitable and convenient one. if you are a developer and working on multiple versions of node then NVM is suitable. Option 2 is a simpler option but it may not prove a latest version. Option 3 is a bit complex one as it involves downloading and configuring source package.

Tejbahadur Singh

Always learner enthusiast finding solutions of technical issues that exist. Web, Blockchain, cybersecurity, web/app security researcher. I am a nerd who can be found reading books, consuming online contents and reading on internet.

2 thoughts on “Different option to install node.js on ubuntu


Leave a Reply

Your email address will not be published. Required fields are marked *