Installing Node.js on Rocky Linux 8

Hello,

In this week’s feature highlight, we look at How to Install Node.js on Rocky Linux 8


Node.js is a JavaScript runtime environment and it is primarily used for non-blocking, event-driven servers, due to its single-threaded nature. It’s used for traditional websites and back-end API services but was designed with real-time, push-based architectures. It offers users the ability to write websites in JavaScript whose code executes on the server instead of a client’s browser.

First, check for the update to keep the server up to date.

yum update -y

Installing Node.js

To list the available Node.js streams.

yum module list nodejs

Output:

[root@server ~]# yum module list nodejs
Last metadata expiration check: 2:07:57 ago on Thu 13 May 2021 01:00:13 PM EDT.
Rocky Linux 8 - AppStream
Name      Stream    Profiles                                Summary
nodejs    10 [d]    common [d], development, minimal, s2i   Javascript runtime
nodejs    12        common [d], development, minimal, s2i   Javascript runtime
nodejs    14        common [d], development, minimal, s2i   Javascript runtime

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

Command to Install Node.js.

yum module install nodejs:14

Output:

[root@server ~]# yum module install nodejs:14
Last metadata expiration check: 2:08:28 ago on Thu 13 May 2021 01:00:13 PM EDT.
Dependencies resolved.
================================================================================
 Package       Arch   Version                                   Repo       Size
================================================================================
Installing group/module packages:
 nodejs        x86_64 1:14.16.0-2.module+el8.3.0+100+234774f7   appstream  11 M
 npm           x86_64 1:6.14.11-1.14.16.0.2.module+el8.3.0+100+234774f7
                                                                appstream 3.7 M
Installing weak dependencies:
 nodejs-docs   noarch 1:14.16.0-2.module+el8.3.0+100+234774f7   appstream 7.9 M
 nodejs-full-i18n

Verify the installed Node.js version using the command,

node -v 

Output:

[root@server ~]# node -v
v14.16.0

This Concludes how you install Node.js on Rocky Linux 8. Now you can begin using it to host your website, along with using npm to install any necessary JavaScript packages.

Uninstalling Node.js

If you can not configure and face any technical difficulties, kindly reach out to us via Support Ticket.

If you wish to uninstall Node.js and npm packages, you can run the command,

yum module remove nodejs

Output:

[root@server ~]# yum module remove nodejs
Last metadata expiration check: 0:24:44 ago on Thu 13 May 2021 04:00:27 PM EDT.
Dependencies resolved.
================================================================================
 Package      Arch   Version                                   Repository  Size
================================================================================
Removing:
 nodejs       x86_64 1:14.16.0-2.module+el8.3.0+100+234774f7   @appstream  36 M
 npm          x86_64 1:6.14.11-1.14.16.0.2.module+el8.3.0+100+234774f7
                                                               @appstream  15 M
Removing unused dependencies:
 nodejs-docs  noarch 1:14.16.0-2.module+el8.3.0+100+234774f7   @appstream  60 M

To verify that node.js is uninstalled you can run the following command,

node --version

Output:

[root@server ~]# node --version
-bash: node: command not found
(Visited 138 times, 1 visits today)