Install Node.js 14 on CentOS 8 / RHEL 8

Node.js is a cross-platform JavaScript runtime environment built on Chrome’s JavaScript designed to execute JavaScript code on the server-side. With Node.js, you can build scalable network applications. The Node.js I/O model, which is based on events and non-blocking operations enables a Developer to write efficient applications. The features of Node.js can be extended with tons of npm modules available.
In this article, we will show you how to install install Node.js on a CentOS 8 / RHEL 8 Linux server.

Installing Node.js 14 on CentOS 8 & RHEL 8

An setup script is available which eases the installation of Node.js 14 on CentOS 8 & RHEL 8. You don’t need to build binaries from source code. The process is as simple as pulling the script and executing it, then run yum install commands.
The script will import RPM GPG key for the repository and create a repository file for Node.js packages.

$ sudo yum -y install curl
$ curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash -

Example output:

$ curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash -
## Installing the NodeSource Node.js 14.x repo...

## Inspecting system...

+ rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release || rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release
+ uname -m

## Confirming "el8-x86_64" is supported...

+ curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_14.x/el/8/x86_64/nodesource-release-el8-1.noarch.rpm'

## As yum will try to install Node.js from the AppStream repository
instead of the NodeSource repository, the AppStream's version of Node.js has to be disabled.
## Run `sudo yum module enable -y nodejs` to reactivate the AppStream's Node.js repository.

+ yum module disable -y nodejs
Failed to set locale, defaulting to C.UTF-8
Node.js Packages for Enterprise Linux 8 - x86_6 199 kB/s | 436 kB     00:02    
Dependencies resolved.
 Package           Architecture     Version             Repository         Size
Disabling modules:

Transaction Summary


## Downloading release setup RPM...

+ mktemp
+ curl -sL -o '/tmp/tmp.ils4abx8tA' 'https://rpm.nodesource.com/pub_14.x/el/8/x86_64/nodesource-release-el8-1.noarch.rpm'

## Installing release setup RPM...

+ rpm -i --nosignature --force '/tmp/tmp.ils4abx8tA'

## Cleaning up...

+ rm -f '/tmp/tmp.ils4abx8tA'

## Checking for existing installations...

+ rpm -qa 'node|npm' | grep -v nodesource

## Run `sudo yum install -y nodejs` to install Node.js 14.x and npm.
## You may also need development tools to build native addons:
     sudo yum install gcc-c++ make
## To install the Yarn package manager, run:
     curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
     sudo yum install yarn

After adding the repository in your system, Your system is ready to install Node.js. Execute the following command to install Node.js and NPM on CentOS 8 /RHRL 8 system.

$ sudo yum install -y nodejs

After installing node.js verify and check the installed version. You can find more details about current version on node.js official website.

$ node -v

To install the Yarn package manager, run:

$ curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
$ sudo yum install yarn

If you need to build native add-ons for Node.js, consider installing the Development Tools.

$ sudo yum install gcc-c++ make


Node.js is a runtime based on the V8 Javascript engine made by google, and originally used in the Chrome browser. By using it we can create applications using Javascript outside the context of a web browser. In this tutorial we saw how to install the nodejs package on RHEL/CentOS Linux 8 Operating system. Please share your feedback in the comments section.

Related Articles

One Comment

  1. Radenko, thanks this was helpful. I wanted to install a later version of Node.js on CentOS 8 and this showed me an easy way to do this without requiring me to download and compile node.js from source code!

Leave a Reply

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


This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top button