# Steps to Install NVM for Node.js on CentOS 8
Node Version Manager, also known as NVM is used to control and manage multiple active versions of Node.js in one system. It is a command line utility and a bash script that allows programmers to shift between different versions of Node.js. They will be able to install any version using a single command and setting defaults using the command line utility.
- These installation instructions are specifically for a CentOS 8 server.
- We are using a Liquid Web VPS server running Cent OS 8 64-bit Core-managed server.
- We are logged in as the Root user.
First, we will need to make sure all of our packages are up to date:
yum update
or
dnf update
Installing NVM (Node Version Manager)
Next, we will need to run the following NVM installation script. This will install the latest version of NVM from GitHub.
[root@host ~]# curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 13527 100 13527 0 0 60932 0 --:--:-- --:--:-- --:--:-- 61208
=> Downloading nvm as script to '/root/.nvm'
=> Appending nvm source string to /root/.bashrc
=> Appending bash_completion source string to /root/.bashrc
=> 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
[root@host ~]#
Finish Update
Once the script completes without errors, we need to run a source command to immediately implement the changes.
[root@host ~]# source ~/.bash_profile
[root@host ~]#
Select Node.js Version
Now NVM is ready to use to install the various versions of Node.JS on our system. To find out all the available versions of Node.JS, we will run the following command. This command will produce a long list of available versions including the LTS versions. LTS stands for Long Term Support.
$ nvm list-remote
v12.13.0 (LTS: Erbium)
v12.13.1 (LTS: Erbium)
v12.14.0 (LTS: Erbium)
v12.14.1 (LTS: Erbium)
v12.15.0 (LTS: Erbium)
v12.16.0 (LTS: Erbium)
v12.16.1 (LTS: Erbium)
v12.16.2 (LTS: Erbium)
v12.16.3 (Latest LTS: Erbium)
v13.0.0
v13.0.1
v13.1.0
v13.2.0
v13.3.0
v13.4.0
v13.5.0
v13.6.0
v13.7.0
v13.8.0
v13.9.0
v13.10.0
v13.10.1
v13.11.0
v13.12.0
v13.13.0
v13.14.0
v14.0.0
v14.1.0
v14.2.0
[root@host ~]#
Install Node.js
Next, install the latest version of Node.js from the v13 release by running the nvm install 13 command. The output should look something like this.
root@host:~# nvm install 13
Downloading and installing node v13.14.0...
Downloading https://nodejs.org/dist/v13.14.0/node-v13.14.0-linux-x64.tar.xz...
################################################################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v13.14.0 (npm v6.14.4)
Creating default alias: default -> 13 (-> v13.14.0)
root@host:~#
Verify the Installation
To review which version of Node.js is currently active, we will run the following command.
[root@host ~]# nvm current
v13.14.0
[root@host ~]#
Switch Between Node.js versions Using NVM
NVM allows the user to manage multiple versions of Node.js. For example, to install the latest stable version of NVM, we will run the following command.
root@host:~# nvm install stable
Downloading and installing node v14.2.0...
Downloading https://nodejs.org/dist/v14.2.0/node-v14.2.0-linux-x64.tar.xz...
######################################################################100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v14.2.0 (npm v6.14.4)
root@host:~#
Installing a new version of Node.js automatically switches from the currently active version to the new updated version. Observe the output of the nvm current command now.
root@host:~# nvm current
v14.2.0
Now that there are two versions of Node.js available. To use v13, we will run the following command to switch back to v13
root@host:~# nvm use v13
Now using node v13.14.0 (npm v6.14.4)
root@host:~#
Lastly, we can always use the nvm help command to get us started on with further node.js management options.
nvm help
NVM makes installing and managing different versions of Node.js effortless. Now that Node.js is installed, your server environment is primed and ready to begin developing your Node.js application!
Would you like more information about setting up an advanced, stable development environment? Simply give us a call today at 800.580.4985, or open a chat or ticket with us to speak with one of our knowledgeable Solutions Team or an experienced Hosting Advisors! We will provide you with reliable information from which you can make an informed decision.
Related Articles:
- 4 Methods for How to Install Yarn on Windows Server
- How to Install Bpytop Resource Monitoring Tool on AlmaLinux
- How to Fix “This Site Can’t Provide a Secure Connection” Error
- How to Install MongoDB on AlmaLinux
- How to Install PostgreSQL on AlmaLinux
- How to Use the WP Toolkit to Secure and Update WordPress
About the Author: David Singer
I am a g33k, Linux blogger, developer, student, and former Tech Writer for Liquidweb.com. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....
Our Sales and Support teams are available 24 hours by phone or e-mail to assist.
Latest Articles
What Is WebP and What Makes it Different from Other Image Formats?
Read ArticleTop 10 Password Security Standards
Read ArticleTop 10 Password Security Standards
Read ArticleHow to Install MongoDB on AlmaLinux
Read ArticleHow to Use the WP Toolkit to Secure and Update WordPress
Read Article