How To Install Node.js On CentOS 8 / RHEL 8


Node.js is an open source, cross-platform JavaScript runtime environment for developing network tools and web applications. Many of the Node.js modules are written in JavaScript which makes the development of applications easier.

Node.js is a combination of the Runtime environment and JavaScript modules. Node.js interprets JavaScript using Google’s V8 JavaScript engine, developed by Ryan Dahl in 2009.

In this post, we will see how to install Node.js on CentOS 8 / RHEL 8.

Node.js Versions

There are two versions of Node.js available for users. Check out the official page to find the latest version of Node.js.

  • v10.x (Long Term Supported)
  • v11.x (Current Latest Version)

Install Build Toos (Optional)

To compile and install native add-ons from npm, you need to install development tools.

yum groupinstall -y 'Development Tools'

Install Node.js on CentOS 8 / RHEL 8

Install Node.js Using NodeSource

At the time of writing, Node.js binary package is not available for RHEL 8 from NodeSource, the maintainer of Node.js package for Enterprise Linux systems.

Install Node.js Using OS Repository

Node.js v10.x is available from the AppStream repository (rhel-8-for-x86_64-appstream-rpms) for RHEL 8 and AppStream for CentOS 8. So, you can simply install it using yum command.

When Node.js installed, NPM (Node Package Manager) will also be installed along with Node.js.

yum install -y @nodejs

Check the Node.js version using the following command.

node -v



Check the npm version.

npm -v



Create Test Web Server

To test the Node.js installation, create a web server and then run it with Node.js.

Create a file called web_server.js.

vi web_server.js

Place the below contents into the web_server.js file.

const http = require('http');
const port = 9000;
const server = http.createServer((req, res) => {
   res.writeHead(200, {'Content-Type': 'text/plain'});
   res.end('Hello World\n');
server.listen(port, () => {
  console.log(`Server running at http://your-ip-add-ress:${port}/`);

Now, start the web server using the below command.

node --inspect web_server.js

When you run the web_server.js file, you will get the following message in your terminal.

Debugger listening on ws://
For help, see:
Server running at http://your-ip-add-ress:9000/

The above output confirms that the web server has been started and listening on port 9000.


Allow the port 9000 in the firewall to access the web application from external machines.

firewall-cmd --permanent --add-port=9000/tcp

firewall-cmd --reload

Test Node.js

Open a web browser and navigate it to the following URL.


You should get the web page like below.

Install Node.js on CentOS 8
Install Node.js on CentOS 8


That’s All. You have successfully installed Node.js on CentOS 8 / RHEL 8. Please share your feedback in the comments section.

You might also like