Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

Install Node.js on Red Hat Enterprise Linux (RHEL 6 and 7)

April 8, 2024
Lucas Holmquist

    Introduction and Prerequisites

    Note:  This tutorial is for those still using RHEL 7/RHEL 6 and need to install a version Node.js.  If you are using a more recent version of RHEL, please see this article

    In this tutorial, you will set your system up to install software from Red Hat Software Collections (RHSCL), which provides the latest development technologies for Red Hat Enterprise Linux. Then, you will install Node.js v8 and run a simple “Hello, World” application. The whole tutorial should take less than 10 minutes to complete.

    Before you begin, you will need a current Red Hat Enterprise Linux 7 (or RHEL 6) server or workstation subscription that allows you to download software and get updates from Red Hat. Developers can get a no-cost Red Hat Enterprise Linux Developer Suite subscription for development purposes by registering and downloading through developers.redhat.com.

    If you need help, see Troubleshooting and FAQ.

    1. Enable Node.js Red Hat Software Collection

    2 minutes

    In this step you will configure your system to obtain software, including the latest dynamic languages, from the RHSCL software repository. Instructions are provided for both the command line (CLI) and graphical user interface (GUI).

    Note for RHEL 6 users: If your system uses Red Hat Network (RHN) Classic instead of Red Hat Subscription Management (RHSM) for managing subscriptions and entitlements, please skip this step and follow the Installation chapter of the Red Hat Software Collections Release Notes. The instructions in this section are only for systems using RHSM. The remainder of this tutorial applies to systems running either RHSM or RHN Classic.

    Using the Red Hat Subscription Manager GUI

    Start Red Hat Subscription Manager using the System Tools group of the Applications menu. Alternatively, you can start it from the command prompt by typing subscription-manager-gui.

    1. Select Repositories from the System menu of the subscription manager.
    2. In the list of repositories, check the Enabled column for rhel-server-rhscl-7-rpms and rhel-7-server-optional-rpms (or rhel-server-rhscl-6-rpms and rhel-6-server-optional-rpms). If you are using a workstation version of Red Hat Enterprise Linux, the repositories will be named rhel-workstation-rhscl-7-rpms and rhel-7-workstation-optional-rpms (or rhel-desktop-rhscl-6-rpms and rhel-6-desktop-optional-rpms). Note: After clicking, it might take several seconds for the check mark to appear in the enabled column.

    If you don’t see any RHSCL repositories in the list, your subscription might not include it. See Troubleshooting and FAQ for more information.

    Using subscription-manager from the command line

    You can add or remove software repositories from the command line using the subscription-manager tool as the root user. Use the --list option to view the available software repositories and verify that you have access to RHSCL:

    $ su -
    
    # subscription-manager repos --list | egrep rhscl

    If you don’t see any RHSCL repositories in the list, your subscription might not include it. See Troubleshooting and FAQ for more information.

    If you are using a workstation edition of Red Hat Enterprise Linux, change -server- to -workstation- in the following commands:

    # subscription-manager repos --enable rhel-server-rhscl-7-rpms
    
    # subscription-manager repos --enable rhel-7-server-optional-rpms

    or for RHEL 6:

    # subscription-manager repos --enable rhel-server-rhscl-6-rpms
    
    # subscription-manager repos --enable rhel-6-server-optional-rpms

    2. Setup your Node.js development environment

    2 minutes

    Next step, install Node.js v4 from RHSCL:

    $ su -
    
    # yum install rh-nodejs8

    Note: In Node.js v8, the JavaScript v8 runtime is built in. A separate package is no longer required.

    3. Hello World and your first Node.js application

    2 minutes

    Under your normal user ID, start a Terminal window. First, use scl enable to add Node.js v4 to your environment, then run Node.js to check the version.

    $ scl enable rh-nodejs8 bash
    
    $ node --version
    
    v8.6.0

    The next step is to create a Node.js program that can be run from the command line. Using a text editor such as vi, nano, or geditcreate a file named hello.js with the following content:

    console.log("Hello, Red Hat Developer Program World from Node " + process.version)

    Save it and exit the editor. Run it with the node command:

    
    
    $ node ./hello.js
    
    Hello, Red Hat Developer Program World from Node v8.6.0
    
    ​

    If you get the error: node command not found, you need to run scl enable rh-nodejs8 bash first.

    The next step is to try a slightly larger Node.js example that implements a tiny web server. Using your preferred text editor, create a file named hello-http.js with the following content:

    var http = require('http');
    
    var port = 8000;
    
    var laddr = '0.0.0.0';
    
    http.createServer(function (req, res) {
    
        res.writeHead(200, {'Content-Type': 'text/plain'});
    
        res.end('Hello, Red Hat Developer Program World from ' +
    
        process.version + '!\n');
    
        console.log('Processed request for '+ req.url);
    
    }).listen(port, laddr);
    
    console.log('Server running at http://' + laddr + ':' + port + '/');

    Save it and exit the editor. Run it with the node command:

    $ node ./hello-http.js

    Now use curl, or a browser such as Firefox, to connect to the Node.js web server http://localhost:8000/:

    $ curl http://localhost:8000/
    
    Hello, Red Hat Developer Program World from v8.6.0!

    Working with RHSCL packages

    The software packages in RHSCL are designed to allow multiple versions of software to be installed concurrently. To accomplish this, the desired package is added to your runtime environment as needed with the scl enable command. When scl enable runs, it modifies environment variables and then runs the specified command. The environmental changes only affect the command that is run by scl and any processes that are run from that command. The steps in this tutorial run the command bash to start a new interactive shell to work in the updated environment. The changes aren’t permanent. Typing exit will return to the original shell with the original environment. Each time you login, or start a new terminal session, scl enable needs to be run again.

    While it is possible to change the system profile to make RHSCL packages part of the system’s global environment, this is not recommended. Doing this can cause conflicts and unexpected problems with other applications because the system version of the package is obscured by having the RHSCL version in the path first.

    Permanently enable RHSCL in your development environment

    To make one or more RHSCL packages a permanent part of your development environment, you can add it to the login script for your specific user ID. this is the recommend approach for development as only processes run under your user ID will be affected.

    Using your preferred text editor, add the following line to your ~/.bashrc:

    # Add Node.js v8 from RHSCL to my login environment
    
    source scl_source enable rh-nodejs8

    After making the change, you should log out and log back in again.

    When you deliver an application that uses RHSCL packages, a best practice is to have your startup script handle the scl enable step for your application. You should not ask your users to change their environment as this is likely to create conflicts with other applications.

    Where to go next?

    If you want to learn more about what Red Hat is up to on the Node.js front, check out our Node.js page here.

    View documentation on the Nodejs.org web site
    http://nodejs.org/documentation/

    Find additional Node.js packages in RHSCL

    $ yum list available rh-nodejs4-\*

    View the full list of packages available in RHSCL

    $ yum --disablerepo="*" --enablerepo="rhel-server-rhscl-7-rpms" list available

    or for RHEL 6:

    $ yum --disablerepo="*" --enablerepo="rhel-server-rhscl-6-rpms" list available

    Want to know more about Software Collections?

    • Read the Red Hat Software Collections Release Notes and Packaging Guide

    Developers should read the packaging guide to get a more complete understanding of how software collections work, and how to deliver software that uses RHSCL. Become a Red Hat developer: developers.redhat.com Red Hat delivers the resources and ecosystem of experts to help you be more productive and build great solutions. Register for free at developers.redhat.com.

     

    Last updated: April 10, 2024
    Disclaimer: Please note the content in this blog post has not been thoroughly reviewed by the Red Hat Developer editorial team. Any opinions expressed in this post are the author's own and do not necessarily reflect the policies or positions of Red Hat.

    Recent Posts

    • LogAn: Large-scale log analysis with small language models

    • stalld’s BPF Backend: Breaking Free from debugfs

    • Running AI inference on Rebellions ATOM NPU with Red Hat AI

    • How we built integration testing for fast-moving AI backend

    • Testing infrastructure red teaming with abliterated models

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Chat Support

    Please log in with your Red Hat account to access chat support.