How to Install Node.JS 14 / 16 & NPM on Rocky Linux 8

Node.js is an open-source, cross-platform, back-end JavaScript runtime environment built on Chrome’s V8 engine to build fast and scalable network applications and back-end APIs. Node.js uses an event-driven, non-blocking IO module that makes it very lightweight and practical. It is a fantastic choice for data-intensive real-time applications that run across distributed devices.

NPM is a package manager for the JavaScript programming language maintained by NPM, Inc. NPM is the default package manager for the JavaScript runtime environment Node.js and is arguably the most available repository for Node.JS packages.

In the following tutorial, you will learn how to install Node.JS in various ways from the app stream and the node source repository on Rocky Linux 8.

Prerequisites

  • Recommended OS: Rocky Linux 8.+.
  • User account: A user account with sudo or root access.

Update Operating System

Update your Rocky Linux operating system to make sure all existing packages are up to date:

sudo dnf upgrade --refresh -y

The tutorial will be using the sudo command and assuming you have sudo status.

To verify sudo status on your account:

sudo whoami

Example output showing sudo status:

[joshua@rockylinux ~]$ sudo whoami
root

To set up an existing or new sudo account, visit our tutorial on How to Add a User to Sudoers on Rocky Linux.

To use the root account, use the following command with the root password to log in.

su

Advertisement


Install Node.JS 14 with Appstream or Source

The first part of installing Node.JS will cover version 14 and 14 LTS from the Rocky Linux 8 App stream and downloading and installing from the source.

Overall, research which version of Node.JS you require; as a developer, most would already know this question; it is always recommended that long-term development sticks with LTS versions much like Linux distributions.

Install Node.JS 14 from Appstream

To install node.js from Rocky Linux 8 App stream, first find out what versions are available as follows:

sudo dnf module list nodejs

Example output:

How to Install Node.JS 14 / 16 & NPM on Rocky Linux 8

As the output shows, node.js 10, 12, and 14 are available; however, for this case, the node.js default module stream is version 10, which you must change.

First, reset the dnf module list nodejs repositories as follows:

sudo dnf module reset -y nodejs

Example output:

Resetting modules:
 nodejs                                                                           

Transaction Summary
===================================================================================

Complete!

To enable version 14, use the following command:

sudo dnf module enable -y nodejs:14

Example output:

Enabling module streams:
 nodejs                               14                                          

Transaction Summary
===================================================================================

Complete!

Next, install node.js using the following DNF command:

sudo dnf install nodejs

Example output:

How to Install Node.JS 14 / 16 & NPM on Rocky Linux 8

Type “Y,” then press “ENTER KEY” to proceed and complete the installation.

To verify the installation and confirm the version build of NPM, use the following command:

npm -v

Example output:

6.14.13

Install Node.JS 14 from Source

The second option is to install node.js from the Nodesource Repository, which provides the latest version of Node.JS 14.

To install Node.JS 14 from the source, use the following curl command:

sudo curl -fsSL https://rpm.nodesource.com/setup_14.x | sudo bash -

Next, run the installation dnf command as follows to install node.js 14:

sudo dnf install nodejs

To verify the installation and confirm the version build of NPM, use the following command:

npm -v

Example output:

6.14.14

As you can see, the default app stream had a node.js version older version has been changed to a much newer version.

Note, you will see a message saying the default Rocky Linux App stream is disabled, and the Nodesource repository will now be used. If you need to go back to the default app stream, use the following command:

sudo dnf module enable -y nodejs

Example output:

Enabling module streams:
 nodejs                                 10                                             

Transaction Summary
========================================================================================

Complete!

Install Node.JS 14 LTS from Source

The third option is to install Node.JS 14 LTS from the NodeSource repository. New users and developers were unaware of what LTS stands for means Long Term Support and is the recommended version for most users. LTS release lines focus on stability, extended support and provide a reliable platform for applications of any scale. Most Node.js users and companies are on Long Term Support lines.

To install Node.JS 14 LTS from the source, use the following curl command:

sudo curl -fsSL https://rpm.nodesource.com/setup_lts.x | sudo bash -

Next, run the installation dnf command as follows to install node.js LTS 14:

sudo dnf install nodejs

To verify the installation and confirm the version build of NPM, use the following command:

npm -v

Example output:

6.14.14

Note, you will see a message saying the default Rocky Linux App stream is disabled, and the Nodesource repository will now be used. If you need to go back to the default app stream, use the following command:

sudo dnf module enable -y nodejs

Example output:

Enabling module streams:
 nodejs                                 10                                             

Transaction Summary
========================================================================================

Complete!

Install Node.JS 16 from Source

To install the absolute latest Node.Js, you will need to install node.js 16 from the source as the Rocky Linux App stream does not feature version 16 yet. On the plus side, installing node.js from the source always means you have the latest build.

To install Node.JS 16 from the source, use the following curl command:

sudo curl -fsSL https://rpm.nodesource.com/setup_16.x | sudo bash -

Next, run the installation dnf command as follows to install node.js 16:

sudo dnf install nodejs

To verify the installation and confirm the version build of node.js, use the following command:

npm -v

Example output:

7.21.0

Note, you will see a message saying the default Rocky Linux App stream is disabled, and the Nodesource repository will now be used. If you need to go back to the default app stream, use the following command:

sudo dnf module enable -y nodejs

Example output:

Enabling module streams:
 nodejs                                 10                                             

Transaction Summary
========================================================================================

Complete!

Advertisement


How to Update Node.JS 14, 14LTS & 16 Source

To update Node.JS, the repository was added to your RPM repository, where you can draw off future updates, meaning you do not need to re-download every time a new update comes out. To check for updates using the dnf update command:

sudo dnf update

If an update is available, use the dnf upgrade command:

sudo dnf upgrade

You should regularly check for updates for your entire system, so you should quickly pick up any new additions.

Comments and Conclusion

In the tutorial, you have learned how to install Node.JS & NPM on your Rocky Linux 8 system, covering the app stream Node.JS 14 and three of the latest version options from the NodeSource repository Node.JS 14, 14 LTS, and 16. Overall, most developers would use the NodeSource repositories depending on what environment you are working in to determine which version you will use.

Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x