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 7

    How To Install Latest Nodejs on CentOS/RHEL 7

    RahulBy RahulMay 12, 20162 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 7 systems with the simple commands.

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

    Install latest nodejs

    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:-

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

    For Stable Release:-

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

    Step 2 – Install Node.js on CentOS

    After adding a yum repository in your system lets install Node.js package. NPM will also be installed with node.js. This command will also install many other dependent packages on your system.

    sudo yum install nodejs 
    
    • Don’t Miss => Yarn Installation ( A Node Modules Manager)

    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 7 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 “Welcome Node.js” text. Create a file demo_server.js

    sudo nano 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/');
    

    Save your file and close.

    Now start the web server using the 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.

    express node.js nodjs npm screen supervisor
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow To Add CentOS 7 Template in XenServer 6.2
    Next Article How to Send Email from Node.js

    Related Posts

    How To Install Node.js on Ubuntu 22.04

    Updated:April 16, 20223 Mins Read

    How To Install NVM on Ubuntu 22.04

    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

    22 Comments

    1. vinoth on March 29, 2022 4:08 pm

      following command not working in rhel8.5 curl -sL https://rpm.nodesource.com/setup_14.x | sudo -E bash –

      Reply
    2. vinoth on March 29, 2022 4:06 pm

      following command not working on RHEL 8.5 curl -sL https://rpm.nodesource.com/setup_14.x | sudo -E bash –

      Reply
    3. Srrm on December 15, 2020 11:58 am

      Works perfect on RHEL 7. Thank you

      Reply
    4. tunnel on May 31, 2020 10:13 am

      Thanks

      Reply
    5. vysocan on November 22, 2019 8:51 am

      Hello,
      for some reason https://rpm.nodesource.com/setup_13.x scripts install 6.x repos on my RHEL 7.7 machine instead of 13.x branch. While https://rpm.nodesource.com/setup_12.x works correctly.
      Took me some time to clear yum and figure out what to do. Maybe such think discourage beginners.

      Reply
    6. Marc on November 5, 2019 9:00 am

      curl -sL https://rpm.nodesource.com/setup_13.x | sudo -E bash –
      $ sudo yum install nodejs
      > Loaded plugins: fastestmirror
      > Loading mirror speeds from cached hostfile
      > * base: centos.mirror.liteserver.nl
      > * extras: centos.ufes.br
      > * updates: centos.mirror.liquidtelecom.com
      > No package nodejs available.

      Reply
      • Rahul on November 12, 2019 9:47 am

        Hi Marc, This is still working for CentOS 7. If you are trying on CentOS 6, the latest version doesn’t support it. You need to install older nodejs version.

        Reply
        • Ratikanta Pradhan on November 26, 2019 11:46 am

          I am using CentOS 6.9, will 12.x version of node support?

          Reply
    7. Matt on August 3, 2019 1:47 pm

      yum repo link is targeting a script for debian systems

      Reply
    8. Dirk on July 23, 2019 10:48 pm

      worked like a charm on Oracle Linux 6. Thanks!

      Reply
    9. Johnathan on July 16, 2019 4:13 pm

      How can I download Nodejs in rpm format?
      I do not have registered yum. I need to find another way.
      Can you please advise on how to do it through rpm?
      Thanks

      Reply
    10. Ernest on June 12, 2019 3:13 pm

      thank you so much, you are the best !. God bless

      Reply
    11. Jaideep on March 25, 2019 10:18 am

      Thank you.

      Reply
    12. Viki on March 17, 2018 11:26 am

      Still I’m getting the error, “This site can’t be reached”.
      127.0.0.1 refused to connect.

      Im using Ec2 here. And I have enabled 3001 port open in security group as well. And also made firewall persistent with the command #firewall-cmd –zone=public –add-port=3001/tcp –permanent. But its still not working. Any help ?

      Reply
      • Rahul K. on March 18, 2018 6:11 am

        Hi Viki, Use below command to check if port is listening

        netstat -tulpn | grep node

        Reply
        • VIKI on March 19, 2018 12:23 pm

          Hi Rahul, Thanks for the reply. Got this fixed. My bad. In your demo script. In the place of “127.0.0.1”, I need to give my EC2’s IP. I didn’t notice it. 🙂

          Reply
    13. kiran on August 30, 2017 7:29 am

      I am having following error
      Error: Package: 1:nodejs-4.8.4-1nodesource.el7.centos.x86_64 (nodesource)
      Requires: libc.so.6(GLIBC_2.15)(64bit)
      Error: Package: 1:nodejs-4.8.4-1nodesource.el7.centos.x86_64 (nodesource)
      Requires: libstdc++.so.6(GLIBCXX_3.4.15)(64bit)
      You could try using –skip-broken to work around the problem
      ** Found 1 pre-existing rpmdb problem(s), ‘yum check’ output follows:
      nodesource-release-el7-1.noarch is a duplicate with nodesource-release-el6-1.noarch

      Could you please help me.

      Reply
    14. Alex on November 20, 2016 5:10 pm

      It doesn’t work on my CentOS 6.8:
      No package nodejs available.

      Reply
    15. vandolph reyes on November 18, 2016 6:24 am

      Hi, Im getting this error in my centos 6 vps.

      after node -v.

      node: error while loading shared libraries: libuv.so.0.10: cannot open shared object file: No such file or directory

      Reply
    16. Justin Mercier on November 13, 2016 7:32 pm

      Thanks for the instructions, but I am really not a fan of executing code directly from a webserver. I’ll inspect it myself but for others I would suggest showing the repo file content that needs to be added rather than saying “blindly run this code on your server in a root shell”.

      Reply
    17. Mike on October 11, 2016 5:47 am

      had to open the firewall using “firewall-cmd –zone=public –add-port=3001/tcp –permanent” then it worked great. Thanks heaps.

      Reply
    18. Jacob on May 21, 2016 4:13 pm

      Working perfect on my Centos 7 system… thanks buddy

      Reply

    Leave A Reply Cancel Reply

    Recent Posts
    • How to Enable / disable Firewall in Windows
    • 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
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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