How to Install NodeJS on Rocky Linux 9

NodeJS 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 NodeJS

To list the available NodeJS streams.

yum module list nodejs


[root@vps ~]# yum module list nodejs
Last metadata expiration check: 0:03:37 ago on Mon 12 Feb 2024 06:55:29 PM UTC.
RockyLinux 9 - AppStream
Name                      Stream                    Profiles                                                 Summary                              
nodejs                    18                        common [d], development, minimal, s2i                    Javascript runtime                   
nodejs                    20                        common [d], development, minimal, s2i                    Javascript runtime                   

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
[root@vps ~]#

Command to Install NodeJS.

yum module install nodejs:20


[root@vps ~]# yum module install nodejs:20
Last metadata expiration check: 0:03:49 ago on Mon 12 Feb 2024 06:55:29 PM UTC.
Dependencies resolved.
 Package                        Architecture         Version                                                        Repository               Size
Installing group/module packages:
 nodejs                         x86_64               1:20.9.0-1.module_el9.3.0+48+1cf146a1                          appstream                14 M
 npm                            x86_64               1:10.1.0-                 appstream               2.0 M
Installing weak dependencies:
 nodejs-docs                    noarch               1:20.9.0-1.module_el9.3.0+48+1cf146a1                          appstream               7.9 M
 nodejs-full-i18n               x86_64               1:20.9.0-1.module_el9.3.0+48+1cf146a1                          appstream               8.5 M
Installing module profiles:
Enabling module streams:
  nodejs-1:20.9.0-1.module_el9.3.0+48+1cf146a1.x86_64                       nodejs-docs-1:20.9.0-1.module_el9.3.0+48+1cf146a1.noarch             
  nodejs-full-i18n-1:20.9.0-1.module_el9.3.0+48+1cf146a1.x86_64             npm-1:10.1.0-            


Command to verify,

node -v 


[root@vps ~]# node -v 
[root@vps ~]# 

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

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