Table of Contents
Install Node.js with npm on CentOS
Where npm stands for Node Package Manager which is the default package manager for Node.js. npm is the worlds largest software registry for Node.js packages with thousands of packages available.
In this tutorial we will install Node.js in following three ways:
- Install Node.js and npm using EPEL repository
- Install Node.js and npm using nvm
curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash -
NOTE : The latest LTS version of Node.js is 10.x if you want to install 8.x version then just replace
After executing above command NodeSource repository is enabled. Now you can install Node.js by using the following command. When it will prompt you to retrieve GPG key just press ‘y’ to continue.
sudo yum install nodejs
Now confirm the installation of Node.js by using the following command
And confirm npm installation with the following command
First, we will install NVM (Node Package Manager) on your system. So download NVM installation script running the following command.
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
As shown in the above output you should close and reopen terminal.
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
The output should be:
You can install multiple versions of Node.js. To do so type following:
nvm install 8.14
nvm install --lts
nvm install 11.3
To list all the versions installed run following command.
You can change the current default version of Node.js by using the following command.
nvm use 8.14
To uninstall a Node.js version type following command
nvm uninstall 11.14