How to Install Node.js on CentOS 8. In this post we will introduce what Node.js is and we will move onto installation on CentOS 8. Let’s start.Â
What is Node.js
Node.js is a free and open source JavaScript runtime environment released in 2009 by Ryan Dahl. It is built on Chrome’s V8 JavaScript engine and used for traditional websites and back end API services. The purpose of designing a server side platform was to help developers create dynamic web page content and build fast network applications. As a result, one could easily create a complete web app development project with the help of a single programming language. Node.js server is fast and scalable server side platform that stores various JavaScript modules helpful in web app developments. Also, using these modules, developers can run applications on OS X, Microsoft Windows, and Linux.
Node.js provides an NPM tool to manage packages for Node.js applications and has the world’s largest software registry. It is gaining popularity due to its ease of development process and delivers efficient performance. It is used by many popular companies, including Netflix, Uber, Walmart, eBay, etc.
Install Node.js from the CentOS AppStream Repository
The simple and easiest way to install Node.js is from the AppStream repository. You can list all Node.js versions included in the AppStream repository with the following command:
dnf module list nodejs
You will get the following output:
Last metadata expiration check: 0:00:01 ago on Monday 07 March 2022 04:14:58 PM UTC.
CentOS 8 - AppStream
Name Stream Profiles Summary
nodejs 10 [d] 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
nodejs 16 common [d], development, minimal, s2i Javascript runtime
As you can see, Node.js 10 is set as the default version. So, if you want to install Node.js 14 you will need to enable it first. You can enable it using the following command:
dnf module enable nodejs:14
You will get the following output:
Last metadata expiration check: 0:00:45 ago on Monday 07 March 2022 04:14:58 PM UTC.
Dependencies resolved.
==============================================================================================================================================
Package Architecture Version Repository Size
==============================================================================================================================================
Enabling module streams:
nodejs 14
Transaction Summary
==============================================================================================================================================
Is this ok [y/N]: y
Once Node.js version 14 is enabled, you can install it by running the following command:
dnf install nodejs -y
Once the Node.js is installed, verify the Node.js version with the following command:
node --version
You will get the following output:
v14.18.2
If you want to remove the Node.js package, run the following commands:
dnf remove nodejs npm
Once you are finished, you can proceed to the next step.
NVM stands for “Node Version Manager” is a Node package manager that is used to manage and switch between different Node versions with ease. It comes with a command line interface to install different Node.js versions using a single command.
You can install the NVM using the curl command as shown below:
Once the NVM is installed, you will get the following output:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 14926 100 14926 0 0 96922 0 --:--:-- --:--:-- --:--:-- 97555
=> Downloading nvm as script to 'https://net.cloudinfrastructureservices.co.uk/root/.nvm'
=> Appending nvm source string to /root/.bashrc
=> Appending bash_completion source string to /root/.bashrc
=> Close and reopen your terminal to start using nvm or run the following to use it now:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
Next, close and reopen your terminal to start using nvm or run the following to use it now:
This guide explained how to install Node.js using three different methods. You can now choose your preferred method to install Node.js on your server. You can now use Node.js to build both front end and back end applications. For more information, visit the Node.js documentation page.
I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.
00votes
Article Rating
Subscribe
Login and comment with
I allow to create an account
When you login first time using a Social Login button, we collect your account public profile information shared by Social Login provider, based on your privacy settings. We also get your email address to automatically create an account for you in our website. Once your account is created, you'll be logged-in to this account.
DisagreeAgree
Login and comment with
I allow to create an account
When you login first time using a Social Login button, we collect your account public profile information shared by Social Login provider, based on your privacy settings. We also get your email address to automatically create an account for you in our website. Once your account is created, you'll be logged-in to this account.