Last Updated on March 13, 2023 by Minerva
In this Tutorial, we will walk you through the steps to install Node.js and npm on a CentOS7 machine. There are many different ways to install and in this tutorial, we will guide you to install using yum package manager.
Before we move to install Node.js and npm. Let’s first understand what is Node.js and npm. We have shared a short description about both.
Node.js is an open-source server environment. It is free and runs on various platforms like Windows, Linux, Unix, Mac OS X etc. It uses JavaScript on the server. Node.js eliminates the waiting time and continue to take the next request. It is asynchronously programming which is very memory efficient.
npm is short of Node Package Manager. It is the world’s largest software registry. open-source developers use npm and share software. npm includes a CLI (Command Line Client) that can be used to download and install the software.
Please follow these steps to install Node.js and npm using the yum package manager from the NodeSource repository.
1. Logged in to the server
Make sure you are logged in as a user with sudo privileges. You can use any command-line tool like putty or any other software to connect to your CentosOS server.
2. Add NodeSource yum repository
The current LTS version of Node.js is version 10.x. If you want to install the older version just change the version number in the commend below. for example setup_10.x to setup_8.x in case you wanted to install version 8.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 –
3. Install Node.js and npm
The previous command will enable the NodeSource repository. You can now type below command to install Node.js and npm:
$ sudo yum install nodejs
You will be asked to import the repository GPG key, type y, and press Enter.
4. Verify the Node.js and npm Installation
Once Node.js and nmp installed, you can run the following commands to check successful installation. This command also print the Node.js and npm versions.
$ node –version
Output
v10.13.0
$ npm –version
Output
6.4.1
5. Install development tools
We will need to install the development tools and libraries to be able to build native modules from npm. Run following command:
$ sudo yum install gcc-c++ make
Contact Us –
📞 Call – +91 8100 665964 (INDIA) | +1 720 738 1011 (US)
📧 Email – hello@minervainfotech.com
👨🏻💻 Skype – minervainfotech