How To Install or Update NodeJs on Rocky Linux

Rocky Linux is a community-supported enterprise operating system designed to be binary-compatible with RHEL (Red Hat Enterprise Linux). To install Node.js on Rocky Linux, you can use either the NodeSource repository or the official package manager, DNF.

Here are the steps to install Node.js using the NodeSource repository:

Method 1: Using NodeSource Repository

  1. Add the NodeSource repository:

    
    sudo dnf install -y https://rpm.nodesource.com/pub_16.x/el/8/x86_64/nodesource-release-el8-1.noarch.rpm
    
        
  2. Install Node.js:

    
    sudo dnf install -y nodejs
    
        
  3. Verify the installation:

    
    node -v
    
    npm -v
    
        

Method 2: Using DNF (Official Repository)

  1. Node.js is available as a module called nodejs in CentOS/RHEL 8 and Fedora.

    
    sudo dnf module install nodejs:<stream>
    
    
  2. where <stream> corresponds to the major version of Node.js. To see a list of available versions:

    
    sudo dnf module list nodejs
    
    
  3. To install the latest NodeJS version, run the command:

    
    sudo dnf module install nodejs:20
    
    
  4. Verify the installation:

    
    
    node -v
    
    npm -v
    
    

Comments

Leave a Reply