In this article, we will have explained the necessary steps to install Node.js on CentOS 7. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.
Install Node.js on CentOS
Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.
sudo yum install epel-release sudo yum update sudo yum install gcc-c++ make
Step 2. Install Node.js with npm on CentOS 7.
- Install Node.js and npm using EPEL repository.
Add node.js yum repository in your system provided by the Node.js official website:
curl -sL https://rpm.nodesource.com/setup_10.x | sudo -E bash -
Now you can install Node.js by using the following command, When prompted to import the repository GPG key, type y, and press Enter:
sudo yum install nodejs
Verify installtion of Node.js and npm running following command:
- Install Node.js and npm using NVM.
First, download the nvm install script run the following command:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
The script will clone the nvm repository from Github to ~/.nvm and add the script Path to your Bash or ZSH profile.
=> Close and reopen your terminal to start using nvm or run the following to use it now: export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
Check nvm version and confirm installation typing:
Now install Node.js by using the following command:
nvm install node
Verify Node.js installation by typing:
Congratulation, you have learned how to install Node.js on CentOS 7. If you have any question, please leave a comment below.