How to Install NodeJS on RedHat
Updated on Oct 5, 2023
Installing Node.js on a RedHat system is just as easy as on Ubuntu, if not easier. Of course, to use this method, your system must be a RedHat one or one of its derivatives. We are using AlmaLinux for this tutorial. Again, you will need a sudo-enabled user or a root-level user. These are the steps you will need to take via DNF:
- dnf module list nodejs - This command will check what Node.js versions are available for installation;
- dnf module install nodejs:20 - This will install the specified version of Node.js. The version goes after the colon in the command, and you might need to prefix the command itself with sudo if you are such a user. You will be prompted to confirm your choice, so just hit y;
- node --version - After the installation is done, check to see its integrity with this command. If the system returns the version you specified, then everything is fine.
Additionally, you can install NVM as we did in our Ubuntu section if you want to switch between Node.js versions quickly.
- curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash - This will download the latest NVM version to your server and install it. At the time of writing v0.39.5 is the latest one, but you should check the README.md file in this repository for the latest version. After the installation is successful, close or refresh your current terminal, after which you can use NVM. It has many commands, but we will focus on the ones that install Node.js;
- nvm list-remote - This will show you which Node.js versions are available for installation;
- nvm install v20.5.1 - The command will install the specified version of Node.js on your server;
- nvm list - This will show you all Node.js versions that are installed on your server;
- nvm use - Finally, you can use this command to switch between Node.js versions. Simply specify the version you saw in the previous command.
Without a doubt, Node.js is one of the easiest pieces of software to install on a server. All it takes is a few commands, several minutes, and it is done!