How to Install Node.js in CentOS 8

Node.js is an open-source, cross-platform lightweight and powerful Javascript run-time environment for server-side programming, built on Chrome’s V8 JavaScript engine and used to create scalable network tools and web applications that require backend functionality.

Recommended Read: 18 Best NodeJS Frameworks for Developers in 2019

In this article, we will show you two different ways to install Node.js on a CentOS 8 Linux server so that you can get started.

Install Node.js from CentOS 8 Repositories

There are a few dependency packages such as C++, make, GCC etc., that you need to install from the default CentOS repositories in order to install the latest version of Node.js on CentOS 8 Linux.

To install these dependency packages, you need to install Development Tools in CentOS 8 using the following yum command.

# yum groupinstall "Development Tools" 
Install Development Tools in CentOS 8
Install Development Tools in CentOS 8

Now list the module that provides package Node.js package from the default CentOS repositories using the following command.

# yum module list nodejs
List Nodejs Module
List Nodejs Module

From the above output, there are four different profiles available, but you need to install only the default profile that highlighted with [d] installs a common set of runtime packages.

To install the default Node.js package on your CentOS 8 system, run the following command.

# yum module install nodejs
Install Nodejs in CentOS 8
Install Nodejs in CentOS 8

If you are a developer, you can install the development profile that will install additional libraries that allows you to build dynamically loadable modules as shown.

# yum module install nodejs/development
Install Nodejs Development Profile in CentOS 8
Install Nodejs Development Profile in CentOS 8

After installing the Node.js package, you can verify the version and location using the following commands.

# node -v
# npm -v 
# which node 
# which npm 
Verify Nodejs Version
Verify Nodejs Version

This is the easiest way to install the Node.js environment on CentOS 8 Linux from the CentOS repositories.

Install Node.js on CentOS 8 Using the Node Version Manager

Another easiest way of installing Node.js is using NVM, the Node version manager – is a bash script that allows you to install, uninstall and maintain multiple Node.js versions on the system.

To install or update NVM on CentOS 8 system, use the following cURL or Wget command to download the recent version of the installation script.

# curl -o- | bash
# wget -qO- | bash
Install NVM in CentOS 8
Install NVM in CentOS 8

The above installation script, install the nvm to your user account. To start using it, you need to first source your .bash_profile.

# source ~/.bash_profile

Now, you can list the available Node.js versions using ls-remote.

# nvm list-remote
Sample Output
       v12.13.0   (LTS: Erbium)
       v12.13.1   (LTS: Erbium)
       v12.14.0   (Latest LTS: Erbium)

Now you can install a specific version of Node by typing any of the releases you see. For example, to get version v13.0.0, you can type.

# nvm install 13.0.0
Install Specific Nodejs Version in CentOS 8
Install Specific Nodejs Version in CentOS 8

Once installation completes, you can list the different versions you have installed by typing.

# nvm ls
List Nodejs Installed Versions
List Nodejs Installed Versions

You can switch between Nodejs versions by typing.

# nvm use v12.14.0
Switch Nodejs Versions
Switch Nodejs Versions

You can also set the default Nodejs version and verify it by running.

# nvm alias default v12.14.0
# nvm ls
# node --version
Set Nodejs Version
Set Nodejs Version

In this article, we have explained two different ways of installing Node.js on your CentOS 8 server. If you are facing any problems with the installation, do ask for help in the comment section below.

Tutorial Feedback...
Was this article helpful? If you don't find this article helpful or found some outdated info, issue or a typo, do post your valuable feedback or suggestions in the comments to help improve this article...

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

1 thought on “How to Install Node.js in CentOS 8”

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


Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.