Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Programming»Nodejs»How To Install Latest Nodejs on CentOS/RHEL 8

    How To Install Latest Nodejs on CentOS/RHEL 8

    RahulBy RahulDecember 24, 20192 Mins ReadUpdated:May 29, 2021

    Node.js is a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications. Latest version node.js yum repository is maintaining by its official website. Use this tutorial to add yum repository and install Latest Nodejs to CentOS/RHEL 8 systems with the simple commands.

    To install specific nodejs version, Visit our tutorial Install Specific Nodejs Version with NVM.

    Installing latest Node.js on CentOS 8

    Step 1 – Add Node.js Yum Repository

    First of all, You need to enable node.js yum repository in your system provided by the Node.js official website. You also need development tools to build native add-ons to be installed on your system.

    For Latest Release:-

    sudo dnf install -y gcc-c++ make 
    curl -sL https://rpm.nodesource.com/setup_16.x | sudo -E bash - 
    

    For Stable Release:-

    dnf install -y gcc-c++ make 
    curl -sL https://rpm.nodesource.com/setup_14.x | sudo -E bash - 
    

    Step 2 – Install Node.js on CentOS 8

    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 system.

    sudo dnf install nodejs 
    
    • Don’t Miss => Installing Yarn on CentOS 8

    Step 3 – Check Node.js and NPM Version

    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  
    
    v16.2.0
    

    Also, check the version of npm.

    npm -v  
    
    7.13.0
    

    You have successfully installed Node.js on your CentOS/RHEL 8 system. You may try a demo HTTP server as given below.

    Step 4 – Create Demo Web Server (Optional)

    This is an optional step. If you want to test your node.js install. Let’s create a web server with the “Welcome Node.js” text. Create a file demo_server.js

    vim demo_server.js 
    

    and add the following content

    var http = require('http');
    http.createServer(function (req, res) {
      res.writeHead(200, {'Content-Type': 'text/plain'});
      res.end('Welcome Node.js');
    }).listen(3001, "127.0.0.1");
    console.log('Server running at http://127.0.0.1:3001/');
    

    Now start the webserver using the below command.

    node --inspect demo_server.js 
    
    Debugger listening on ws://127.0.0.1:9229/9e0c7b4a-2ffe-48df-a4b0-b4635dcd9359
    For help, see: https://nodejs.org/en/docs/inspector
    Server running at http://127.0.0.1:3001/
    

    Web server has been started on port 3001. Now access http://127.0.0.1:3001/ url in browser.

    CentOS 8 NodeJs
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Install Tomcat 9 on CentOS/RHEL 8
    Next Article How to Install Yarn on CentOS 8

    Related Posts

    How To Install NVM on Ubuntu 22.04

    Updated:April 16, 20223 Mins Read

    How To Install NVM on Windows

    Updated:April 16, 20223 Mins Read

    How To Install Node.Js on Debian 11

    Updated:February 11, 20226 Mins Read

    How To Install NVM on Debian 11

    Updated:August 31, 20213 Mins Read

    How To Use Environment Variables in Node.js

    6 Mins Read

    How to Parse Command Line Arguments in Node.js

    5 Mins Read

    2 Comments

    1. "Tim" Timmins on March 17, 2020 2:17 am

      Just browsing a few links after reviewing python3 setup notes for Centos 8

      This article is quick, straight forward and helpful (I remember using Node.js 3-4 years ago — would have been helpful).

      SUGGESTION: Its 2020. Update Step 2 to use python3 (and pip3) as python 2 deprecated in January of this year.

      Reply
    2. Daniel Ellis on January 3, 2020 12:46 pm

      Hey,
      I appreciate the fact that you have explained all the information in-depth and step-by-step.
      It really helped me a lot.
      Especially, those who didn’t know how to install nodejs on centos 8, they will get support for sure.
      Thanks for sharing.

      Reply

    Leave A Reply Cancel Reply

    Recent Posts
    • How to Install JAVA on Ubuntu 22.04
    • Switching Display Manager in Ubuntu – GDM, LightDM & SDDM
    • Changing the Login Screen Background in Ubuntu 22.04 & 20.04
    • How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04
    • (Resolved) Please install all available updates for your release before upgrading
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.