How to Install Node.js and npm on Linux CentOS 7 RHEL

The node.js in most cases in daily usage is used for Laravel and Magento platforms, but not only, for example, but some developers also use the npm-sass module to compress theme CSS files and increase web performance. As we know from our experience this is the new modern development way.

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.

In this how-to, we will show you two different ways of installing Node.js and npm.

In the first part of this how-to, we will install Node.js and npm using the yum package manager from the NodeSource repository. In the second part, we will teach you how to install Node.js and npm

If you need Node.js only for deploying Node.js applications then the simplest option is to install the Node.js packages using yum from the NodeSource repository.

Installing Node.js and npm on Linux CentOS 7 and RHEL

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:

 

We need to 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 curl command to add the NodeSource yum repository to your system:

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

Install Node.js and npm

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

sudo yum -y install nodejs
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 --version

The output should be:

v10.13.0

Print npm version:

npm --version

The output should be:

6.4.1

If you would need to install nvm then you can find a how-to in our entry here


Warning: file_get_contents(http://api.wipmania.com/3.235.60.144?[YOUR SITE URL]): failed to open stream: Connection refused in /var/www/vhosts/amberit.eu/httpdocs/wp-content/themes/amberit/inc/layout-functions.php on line 821