How to Install NodeJS 14 / 16 & NPM on Rocky Linux 8

Built on Chrome’s V8 engine, Node.JS is open-source, and event-driven Javascript runtime that is designed to build scalable applications and backend APIs. NodeJS is lightweight and efficient, thanks to its non-blocking I/O model and event-driven architecture. This makes it a perfect choice for handling data-intensive real-time applications. It is cross-platform and totally free to download and use.

NPM is an acronym for Node Package Manager, which is the default package manager for Node.JS and the richest repository for Node.JS packages.

[ You might also like: 3 Top Node.js Package Managers for Linux ]

In this article, we focus on how to install NodeJS & NPM on Rocky Linux 8.

There are two main ways of installing NodeJS on Rocky Linux 8.

  1. Installing from the default Rocky Linux AppStream repository.
  2. Installing from Node.JS binary distributions supported by Nodesource.

Let’s have a look at each of these methods.

Install Node.JS from Rocky Linux AppStream Repositories

Rocky Linux AppStream repositories provide Node.JS as a module called nodejs. Therefore, there’s no need to add or enable any third-party repositories. The downside is that the versions provided are not up to date, but will nonetheless get the job done.

To check out the available versions provided, run the command:

$ sudo dnf module list nodejs

From the output, the latest stream is NodeJS 14. However, the default module stream is nodejs 10.

Check NodeJS Versions
Check NodeJS Versions

To enable the latest NodeJS stream, run the command:

$ sudo dnf module install nodejs:14
Enable NodeJS Stream
Enable NodeJS Stream

Then install NodeJS using the DNF package manager as shown.

$ sudo dnf install nodejs
Install NodeJS in Rocky Linux
Install NodeJS in Rocky Linux

Once installed, verify the version of Node.JS installed as follows.

$ node -v
OR
$ node ---version

v14.16.0

To check the version of NPM, run:

$ npm -v
OR
$ npm ---version

Install Node.JS from Nodesource Repositories

The second option is to install Node.JS from the Node.JS binary package which is provided by nodesource. This provides the latest version of Node.JS which, at the time of writing this guide, is Node.JS v16.5.

So, grab the setup script and run it as shown using curl command.

$ curl -fsSL https://rpm.nodesource.com/setup_16.x | sudo -E bash -
Download NodeJS Installer
Download NodeJS Installer

Then install Node.JS.

$ sudo dnf install nodejs
Install NodeJS from Nodesource
Install NodeJS from Nodesource

Once again, verify the installation of Node.JS as shown.

$ node -v
OR
$ node ---version

v16.5.0

And NPM as well.

$ npm -v

7.19.1
Conclusion

In this tutorial, we have highlighted two ways of installing Node.JS & NPM on Rocky Linux – installation from Rocky Linux repositories and from the Nodesource repository. We do hope that this guide was helpful and that you can now proceed with creating your applications.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

James Kiarie
This is James, a certified Linux administrator and a tech enthusiast who loves keeping in touch with emerging trends in the tech world. When I'm not running commands on the terminal, I'm taking listening to some cool music. taking a casual stroll or watching a nice movie.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

2 Comments

Leave a Reply
  1. Hi,
    curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
    should actually be:
    curl -fsSL https://rpm.nodesource.com/setup_16.x | sudo -E bash -

    Thanks

    Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.