If you’re a developer whether frontend or backend, there are high chances that you’ve likely used Node, npm, or the yarn package manager.
Some of the features of Node js are:
- Node js has an event loop that manages and queues the functions and callbacks. The event-driven architecture executes the function when a particular event is triggered.
- Node js is highly scalable due to its non-blocking asynchronous nature. If there are multiple requests, it can handle them asynchronously.
- The npm is the package manager of Node js. It handles the repositories of various open-source projects. It also handles the dependencies of the project and installed node modules.
- It’s ideal for real-time applications like chat systems that require real-time synchronization. For example chat applications because of the non-blocking asynchronous nature.
Working with Ubuntu 18.04? Read this article on how to Install Node.JS on Ubuntu 18.04
Prerequisites for Installing Node.js on Linux
There aren’t many prerequisites before installation just take care of these:-
- Node version – There are the latest and LTS (Long term support) version. You can decide whichever you want but mostly it is recommended to have an LTS version.
- Update your package manager repositories and your system as well.
- You should have administrative privileges for installation.
- A stable internet connection for downloading node js.
Step-by-Step Guide to Installing Node.js on Linux
We’ve listed multiple ways to install Node js on popular Linux distros.
Installing Node.js Using Snap
If Snap is installed on your system, then it is pretty easy to install Node. Just use the following command:-
sudo snap install node --classic
--classic allows access to system resources.
Installing Node.js on Ubuntu and Debian
You can use the Node.js binary distributions to install it on your system. The binary distributions are available on NodeSource.
Open the terminal and write the following command:-
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - &&\
sudo apt-get install -y nodejs
sudo -E preserves the user environment.
curl -fsSL https://deb.nodesource.com/setup_20.x | bash - &&\
apt-get install -y nodejs
Installing Node.js on CentOS, Fedora, and RHEL
Node js is available in
dnf package manager repositories. You can install it by the following command:-
dnf module install nodejs:<version>
<version> should be replaced with the desired version.
A list of available versions can be obtained through the command:-
dnf module list nodejs
An alternate way to install Node js on CentOS, Fedora, and Red Hat Enterprise Linux
The Node.js binary distributions can be used to install Node.js on your system. To do so use the following command:-
If you have root privileges
curl -fsSL https://rpm.nodesource.com/setup_20.x | bash -
If you don’t have root privileges
curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash -
Installing Node js on Arch Linux
pacman the package manager has the node js package in its repository. It can be installed by the command:-
We recommend installing npm as well, which can be done through the following command:-
pacman -S npm
Verifying Node.js Installation on Linux
You can use the following command to check if Node js is installed in your system:-
The installation process is not very difficult. You just have to be a sudo or root user in most cases to install node js in your system. We’ve listed methods to install node js in various Linux distros in the above sections. Give node js a try, a lot of people use it. If you run into any problems there are chances that you’ll find some solution on forums like stack overflow. It has a huge ecosystem and would fulfil your needs. Ready to elevate your development game? Dive into Node.js and discover why it’s the go-to choice for modern web development. What project will you tackle first with Node.js?
Official Node js website