If you are running Rocky Linux 8.4, the following steps will help you install NodeJS.
Check the NodeJS modules on AppStream repositories
NodeJS is available in Rocky Linux AppStream repositories. To see the available NodeJS modules, run the following command:
$ sudo dnf module list nodejs
From the output on the terminal, you can clearly see that the default module with a tag [d] is NodeJS 10 – which is not the latest version or up to date.
Install the latest NodeJS release
Therefore, to install the latest release of NodeJS, which at the time of this guide is NodeJS 14.x, invoke the command:
$ sudo dnf module install nodejs:14
This installs the latest NodeJS module alongside NPM ( Node Package Manager ) and other dependencies as shown in the output.
The installation of Node.JS proceeds and terminates successfully without any erros as shown below, as should be in your case.
Once complete, verify the NodeJS version as shown.
$ node -v
$ node --version
And that’s how you install NodeJS on Rocky Linux 8. You can now start building your backend services and deploying them.
How to uninstall NodeJS
To remove NodeJS from your system simply execute:
$ sudo dnf module remove nodejs
To confirm that NodeJS is uninstalled, check the version once again.
$ node -v
The output above confirms that NodeJS is uninstalled.
As you have noted, the installation of NodeJS is quite seamless and straightforward. This will work the same even on CentOS 8 from which Rocky Linux is based.
Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications including CCNA RS, SCP, and ACE. As an IT engineer and technical author, he writes for various websites.