In this blog post, you will learn how to quickly install Node.js/NPM on Rocky Linux 8. Node.js is an asynchronous event-driven JavaScript runtime used to build reliable network applications. npm on the other hand is the default package manager for the JavaScript runtime environment Node.js.
Install Node.js/NPM on Rocky Linux 8
The default Rocky Linux AppStream repos provides modules for Node.js;
dnf module list nodejs
Sample output;
Rocky Linux 8 - AppStream
Name Stream Profiles Summary
nodejs 10 [d][e] 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
From the output above, you can see that there are modules of Nodejs 10, 12, 14. WIth modules for Node.js 10 enabled by default.
If you run the command dnf install nodejs
, it will install Node.js 10.x
If you therefore want to install, say Node.js 14.x, you need to enable the module for Node.js 14, then reset the module and enable module for Node.js 14.x
dnf module reset nodejs -y
dnf module enable nodejs:14
Dependencies resolved.
============================================================================================================================================================================
Package Architecture Version Repository Size
============================================================================================================================================================================
Enabling module streams:
nodejs 14
Transaction Summary
============================================================================================================================================================================
Is this ok [y/N]: y
Once that is done, you can then install Node.js 14.x
dnf install nodejs
Sample output;
Dependencies resolved.
============================================================================================================================================================================
Package Architecture Version Repository Size
============================================================================================================================================================================
Installing:
nodejs x86_64 1:14.16.0-2.module+el8.3.0+100+234774f7 appstream 11 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 x86_64 1:14.16.0-2.module+el8.3.0+100+234774f7 appstream 7.5 M
npm x86_64 1:6.14.11-1.14.16.0.2.module+el8.3.0+100+234774f7 appstream 3.7 M
Transaction Summary
============================================================================================================================================================================
Install 4 Packages
Total download size: 30 M
Installed size: 138 M
Is this ok [y/N]: y
Checking the version of Node.js installed;
node -v
v14.16.0
NPM is also installed along-side Node.js;
npm -v
6.14.11
Install Current Stable Release version of Node.js
According to Node.js release page, Node.js v16 is the current stable release as of this writing;
Thus, to install current stable release version of Node.js, you need to install the specific version repository. You can get repository installation script of the specific OS version on Node.js sources distributions page.
For example, run the command below to install Node.js v16.x repository on Rocky Linux 8.
curl -fsSL https://rpm.nodesource.com/setup_16.x | bash -
Next, install Node.js on Rocky linux 8;
dnf install nodejs
Dependencies resolved.
============================================================================================================================================================================
Package Architecture Version Repository Size
============================================================================================================================================================================
Installing:
nodejs x86_64 2:16.5.0-1nodesource nodesource 31 M
Installing dependencies:
python3-pip noarch 9.0.3-19.el8.rocky appstream 19 k
python3-setuptools noarch 39.2.0-6.el8 baseos 162 k
python36 x86_64 3.6.8-2.module+el8.4.0+597+ddf0ddea appstream 18 k
Enabling module streams:
python36 3.6
Transaction Summary
============================================================================================================================================================================
Install 4 Packages
Total download size: 31 M
Installed size: 87 M
Is this ok [y/N]: y
Checking the version of Node.js installed;
node -v
v16.5.0
NPM is also installed along-side Node.js;
npm -v
7.19.1
And there you go.
That marks the end of our tutorial on how to install Node.js/NPM on Rocky Linux 8.
Read more on Node.js guides page.
Other Tutorials
ELK: Send Alerts when no data is received on an index
Install and Setup Wazuh Server with ELK Stack on Ubuntu 20.04