How to Install Node.js and npm on CentOS 7

Rahmati Academy

Node.js is a cross-platform JavaScript run-time environment that allows server-side execution of JavaScript code. Node.js is mainly used on the back-end, but it is also popular as a full-stack and front-end solution.

npm, short for Node Package Manager is the default package manager for Node.js and the world’s largest software repository for the publishing of open-source Node.js packages.

1. Add NodeSource yum repository

The current LTS version of Node.js is version 10.x. Run the following curl command to add the NodeSource yum repository to your system:

curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash -

2. Install Node.js and npm

Once the NodeSource repository is enabled, install Node.js and npm by typing:

sudo yum install nodejs

3. Verify the Node.js and npm Installation

To check that the installation was successful, run the following commands which will print the Node.js and npm versions.

[root@localhost ~]# node --version
v10.24.1
[root@localhost ~]# npm --version
6.14.12

Last updated