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.
This tutorial walks you through the steps to install Node.js and npm on a CentOS 7 machine. We will show you two different ways of installing Node.js and npm.
In the first part of this tutorial 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 using the nvm script.
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.
Prerequisites
Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges.
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 curl command to add the NodeSource yum repository to your system:
2. Install Node.js and npm
Once the NodeSource repository is enabled, install Node.js and npm by typing:
When prompted to import the repository GPG key, type y, and press Enter.
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.
This tutorial walks you through the steps to install Node.js and npm on a CentOS 7 machine. We will show you two different ways of installing Node.js and npm.
In the first part of this tutorial 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 using the nvm script.
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.
Prerequisites
Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges.
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 curl command to add the NodeSource yum repository to your system:
Code:
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:
Code:
sudo yum install nodejs
When prompted to import the repository GPG key, type y, and press Enter.