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 https://deb.nodesource.com/setup_lts.x | sudo -E bash -
Install Node.js latest version
curl -fsSL https://deb.nodesource.com/setup_xx.x | sudo -E bash -
curl -fsSL https://deb.nodesource.com/setup_17.x | sudo -E bash –

sudo apt-get install -y nodejs

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
KEYRING=/usr/share/keyrings/nodesource.gpg
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | 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.
VERSION=node_8.x
KEYRING=/usr/share/keyrings/nodesource
DISTRO="$(lsb_release -s -c)"
echo "deb [signed-by=$KEYRING] https://deb.nodesource.com/$VERSION $DISTRO main" | sudo tee /etc/apt/sources.list.d/nodesource.list
echo "deb-src [signed-by=$KEYRING] https://deb.nodesource.com/$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.
Source: Linux Tutorials, FOSS Reviews, Security News