In this tutorial, we will show you how to install Node.js on CentOS Stream 9. For those of you who didn’t know, Node.js is an open-source, cross-platform lightweight, and powerful Javascript run-time environment for server-side programming, built on Chrome’s V8 JavaScript engine and used to create scalable network tools and web applications. When you install NodeJS on your CentOS, the supportive npm packages are also automatically installed on your system allowing developers to share and reuse the code.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of Node.js on a CentOS Stream 9.
Prerequisites
- A server running one of the following operating systems: CentOS 9 Stream.
- It’s recommended that you use a fresh OS install to prevent any potential issues
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install Node.js on CentOS Stream 9
Step 1. First of all, make sure that all packages are up to date.
sudo dnf update sudo dnf groupinstall "Development Tools"
Step 2. Installing Node.js on CentOS Stream 9.
By default, Node.js is available on CentOS Stream 9 base repository. Now we install the default Node.js package on your CentOS system:
sudo dnf install nodejs
Check the version once the installation is complete:
node --version
In addition, you can install a specific Node.js version using NVM. Now run the following command below to install it:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
Then, execute the command below:
source ~/.bash_profile nvm list-remote nvm install 16.13.2
Verify your version of Node.js installed:
node -v
If you wish to uninstall Node.js and npm packages, you can run the command:
sudo dnf module remove nodejs
Congratulations! You have successfully installed Node.js. Thanks for using this tutorial for installing Node.js on CentOS Stream 9 system. For additional help or useful information, we recommend you check the official Node.js website.