Signup/Sign In

How To Install Node.js And npm On CentOS 7

Node.js is a server-side programming framework based on Javascript. It enables users to construct networked apps with backend functionality quickly and simply. Development may be quick and consistent by adopting Javascript as both the client and server language.

In this post, we'll teach you how to install Node.js on a CentOS 7 server in a few different methods so you can get started. The EPEL installation instructions or the NVM installation processes will be preferred by the majority of users.

Installing Node from the source code

Obtaining the source code and compiling it yourself is one method of obtaining Node.js.

To do so, go to the project's website and download the source code. Right-click the "Source Code" link on the downloads page and choose "Copy link address" or whatever comparable option your browser provides.

To download the archive file, run wget on your server and paste the URL you copied:


Type: to extract the archive and move it to the new directory: to extract the archive and move it to the new directory

tar xzvf node-v* && cd node-v*

In order to build the code, we'll need to download a few items from the CentOS repository. To acquire them right now, use yum:

sudo yum install gcc gcc-c++

We can now setup and build the program as follows:


It will take a long time to put everything together. When it's completed, type:

sudo make install

You may ask Node to show its version number to see whether the installation was successful:

node --version

If you see the version number, it means the installation went well.

Install a Node Site Package

Another way to install Node.js on your server is to simply download and install the pre-built packages from the Node.js website.

The Linux binary packages may be found here. Because CentOS 7 is only available in 64-bit architecture, right-click on the "64-bit" link under "Linux Binaries (.tar.gz)". Choose "Copy link address" or a similar option from your browser's menu.

Change to your home directory on your server and use the wget program to get the files. As the parameter for the command, paste the URL you just copied:

cd ~

Note that the version number in your URL is likely to vary from the one shown above. Instead of the particular URL supplied in this instruction, use the address you obtained from the Node.js site.

With the tar command, we'll extract the binary package into our system's local package hierarchy. The archive is bundled in a versioned directory, which we may remove by using —strip-components 1. With the -C option, we'll define our command's destination directory:

sudo tar --strip-components 1 -xzvf node-v* -C /usr/local

This will install all of the components in your system's /usr/local branch.

By requesting Node for its version number, you may confirm that the installation was successful:

node --version

You may now use Node.js on your CentOS 7 server once the installation has been completed successfully.

Use the EPEL Repository to install Node.

The EPEL (Extra Packages for Enterprise Linux) repository, which is available for CentOS and comparable distributions, is another option for installation.

You must change the repo-list of your installation to acquire access to the EPEL repo. Fortunately, we can re-enable access to this repository by installing the epel-release package from our current repositories.

sudo yum install epel-release

Now that you have access to the EPEL repository, you can use your standard yum instructions to install Node.js:

sudo yum install nodejs

You may double-check that the installation went OK by asking Node for its version number:

node --version

Many users will want to use npm to manage their Node packages as well. You may also download it through EPEL if you search for:

sudo yum install npm

The Node Version Manager is a tool that allows you to manage the versions of your nodes.

NVM, the Node version manager, is another very flexible method of deploying Node.js. This piece of software enables you to simultaneously install and manage many separate versions of Node.js and their accompanying Node packages.

Visit the project's GitHub website to install NVM on your CentOS 7 system. The curl or wget command may be found in the README file on the main page. This will direct you to the most current installation script version.

It's usually a good idea to audit the script before piping it to bash to make sure it's not doing anything you don't agree with. Remove the | bash element from the end of the curl command to do this:


Examine it and make sure you're OK with the adjustments it's making. When you're done, repeat the command again, this time adding | bash to the end. The URL you use will vary based on the most recent version of NVM, however for now, you may download and run the script by typing:

curl | bash

The nvm script will now be installed in your user account. You must first source your.bash profile in order to utilize it:

source ~/.bash_profile

You may now ask NVM which versions of Node it is aware of:

nvm list-remote
. . .

By inputting any of the releases you see, you may install a version of Node. For example, to get version 0.10.30, type:

nvm install v0.10.30

By typing: you can view the various versions you have installed.

nvm list
->  v0.10.30

Switching between them is as simple as typing:

nvm use v0.10.30
Now using node v0.10.30

Type: to make this version the default.

nvm alias default v0.10.30
default -> v0.10.30

Using the same method as in the previous sections, you may check that the installation was successful by typing:

node --version

We can determine that Node is installed correctly on our PC based on the version number output.


As you can see, there are a variety of options for getting Node.js installed on your CentOS 7 server. If you're having trouble with one of the installation methods, try one of the others.