How to Install Node.js on Ubuntu?

The most popular Javascript runtime is Node.js, which uses the V8 engine to perform useful tasks such as interacting with local storage. Node.js has boosted the popularity of Javascript, which was already well-known. Previously, Javascript was only used in web browsers to create interactive web applications; however, with Node.js, we can now use Javascript to create command-line applications, as well as web applications that are designed and even backed by Javascript.

In this article, we will not go into greater detail about Node.js and its functionality. In this article, we will learn how to install Node.js on Ubuntu Linux.

How to install Node.js on Ubuntu?

At the time of writing this article, 16.13.0 is the latest LTS (Long-term Support) version of Node.js, and 17.1.0 is the latest release of Node.js.

For newcomers, 17.1.0 is a good place to start because it contains all of the most recent features released by the developers. It is strongly advised to develop your app in the LTS version for production because it will receive all security and maintenance updates for an extended period of time.

Install Node.js LTS version

curl -fsSL | sudo -E bash –

Please replace x with the LTS version you wish to install.

Install Node.js latest version

curl -fsSL | sudo -E bash –

Do not forget to replace xx.x with the Node.js version you want to install. For example, to install Node.js 17.1.0, replace xx.x with 17.x

curl -fsSL | sudo -E bash –

Add Node.js repository

sudo apt-get install -y nodejs

Install Node.js in Ubuntu

You can use these instructions on any Ubuntu-based Linux distribution. As you can see, I am using Pop!_OS for this article. If you are installing Node.js on a minimal version of Ubuntu that does not have curl and sudo setup, you can install curl and sudo using the following command –

apt install curl sudo

You can install it manually if you do not want to use the above method for whatever reason.

Installing Node.js manually in Ubuntu

curl -fsSL | gpg –dearmor | sudo tee “$KEYRING” >/dev/null

Now open the terminal, customize and pass the following commands one-by-one. Or you can also write a shell script and run it.

Replace the value of VERSION with the Node.js version you want to install. If your distribution lacks the lsb_release command, you can manually assign the DISTRO value or install lsb_release using this article.

DISTRO=”$(lsb_release -s -c)”

echo “deb [signed-by=$KEYRING]$VERSION $DISTRO main” | sudo tee /etc/apt/sources.list.d/nodesource.list

echo “deb-src [signed-by=$KEYRING]$VERSION $DISTRO main” | sudo tee -a /etc/apt/sources.list.d/nodesource.list

Update the system and install Node.js –

sudo apt-get update
sudo apt-get install nodejs

The post How to Install Node.js on Ubuntu? appeared first on Linux Tutorials, FOSS Reviews, Security News.

Leave a Reply

Your email address will not be published.