Installing Node.js and npm on CentOS 7

NodeSource is a company dedicated to providing enterprise-grade Node support and they maintain a consistently-updated Node.js repository for Linux distributions.

To install Node.js and npm from the NodeSource repositories on your CentOS 7 system, follow these steps:

1. Add NodeSource yum repository

The current LTS version of Node.js is version 10.x. If you want to install version 8 just change setup_10.x with setup_8.x in the command below.

Run the following to add the NodeSource yum repository to your system:

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

2. Install Node.js and npm

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

sudo yum install nodejsCopy

When prompted to import the repository GPG key, type y, and press Enter.

 

 

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.

Print Node.js version:

node --versionCopyv10.13.0 Copy

Print npm version:

npm --versionCopy6.4.1 Copy

How to install Node.js and npm using NVM

NVM (Node Version Manager) is a bash script used to manage multiple active Node.js versions. NVM allows us to install and uninstall any specific Node.js version which means we can have any number of Node.js versions we want to use or test.

Leave a Comment
No Comments found