Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Programming»Nodejs»How To Install Latest Node.Js on Amazon Linux 2

    How To Install Latest Node.Js on Amazon Linux 2

    By RahulJanuary 26, 20232 Mins Read

    Node.js is a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications. The latest version node.js yum repository is maintained by its official website. Use this tutorial to add a yum repository and install Latest Nodejs to Amazon Linux systems.

    Advertisement

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

    Step 1 – Configure Yum Repository

    First of all, You need to enable the 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 yum install -y gcc-c++ make 
    curl -sL https://rpm.nodesource.com/setup_19.x | sudo -E bash - 
    

    For Stable Release:-

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

    Step 2 – Install Node.js on Amazon Linux 2

    After adding a yum repository to your system let’s install the 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 -y nodejs 
    
    • Don’t Miss => Yarn Installation ( A Node Modules Manager)

    Step 3 – Check Version

    After installation checks the installed version of Node.js. You can find more details about the current version on node.js official website.

    node -v  
    
    v19.2.0
    

    Also, check the version of npm.

    npm -v  
    
    8.19.3
    

    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(3000, "127.0.0.1");
    console.log('Server running at http://127.0.0.1:3000/');
    

    Now start the web server using the command.

    node --inspect demo_server.js 
    
    Debugger listening on ws://127.0.0.1:9229/8136b052-2b35-402e-8c5c-1d15b027a970
    For help, see: https://nodejs.org/en/docs/inspector
    Server running at http://127.0.0.1:3000/
    

    Therefore the web server has been started on port 3000. Now access http://127.0.0.1:3000/ URL in the browser.

    Amazon Linux install node.js node.js NodeJs
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    How to list all collections in MongoDB database

    How to Install Grunt on Ubuntu 22.04 & 20.04

    Running “npm start” with PM2

    View 7 Comments

    7 Comments

    1. Roger on January 18, 2023 1:48 pm

      On the official github nodejssource, as well as on aws documentation, says the following:

      WARNING: BUILD SYSTEM CURRENTLY BROKEN FOR NODEJS 18+

      You need to install nodejs v16

      Reply
    2. Immnuvel on August 27, 2022 6:45 am

      While performing the steps I am getting below erro

      [[email protected] ~]$ sudo yum install -y nodejs
      Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
      amzn2-core | 3.7 kB 00:00
      Resolving Dependencies
      –> Running transaction check
      —> Package nodejs.x86_64 2:18.8.0-1nodesource will be installed
      –> Processing Dependency: libc.so.6(GLIBC_2.28)(64bit) for package: 2:nodejs-18 .8.0-1nodesource.x86_64
      –> Processing Dependency: libm.so.6(GLIBC_2.27)(64bit) for package: 2:nodejs-18 .8.0-1nodesource.x86_64
      –> Finished Dependency Resolution
      Error: Package: 2:nodejs-18.8.0-1nodesource.x86_64 (nodesource)
      Requires: libc.so.6(GLIBC_2.28)(64bit)
      Error: Package: 2:nodejs-18.8.0-1nodesource.x86_64 (nodesource)
      Requires: libm.so.6(GLIBC_2.27)(64bit)
      You could try using –skip-broken to work around the problem
      You could try running: rpm -Va –nofiles –nodigest

      Reply
      • omar on September 8, 2022 3:26 am

        i have the same problem

        Reply
    3. Nikesh Singh on July 8, 2021 6:19 pm

      Thank you for quick steps! This is very helpful.

      Reply
    4. Harnish on December 23, 2020 12:07 am

      Thank you for this article. this really helped me install node on my Amazon linux 2

      Reply
    5. Rick on October 19, 2020 9:56 pm

      I’ve just tried this and it shows that the nodesource repository got added to my AWS instance, but it says “No package node.js is available.”

      Reply
    6. Anuj Joshi on February 19, 2020 4:53 am

      Rahul, you have written the required article. I want to tell you that I was searching for some solution for installing node.js on my amazon virtual machine. Fortunately, you helped me through this article.

      Now, I will perform the instructions mentioned here so that I could get my task done. Thank you.
      Please keep sharing and writing such small tutorials.

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • How to List Manually Installed Packages in Ubuntu & Debian
    • 10 Bash Tricks Every Developer Should Know
    • How to Validate Email Address in JavaScript
    • Firewalld: Common Firewall Rules and Commands
    • 12 Apk Commands in Alpine Linux Package Management
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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