How Install Nodejs via NVM – Node Version Manager and Useful Commands

by Sandy

In this tutorial we’ll install NVM – Node Version Manager, NVM provides an option for easy installation of Node.js also you can also install specific version of  Node.js and multiple Node.js versions on the same system using nvm and use required version for application. NVM will solve the issue with the different versions are required for your application.

This tutorial will work on many OS and at the time I tested with Ubuntu and CentOS including control panels centos webpanel – CWP, vestacp, cpanel, webmin, diretadmin etc.

Lets get Started :

Step 1 :

For Ubuntu install cURL first :

apt-get install curl -y

Install NVM from Git :

curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash

You can close the ssh session and start it again or Reload system environment via this command :

Centos :

source ~/.bashrc

Ubuntu :

source ~/.profile

Lists Of NVM commands :

To list all nodejs version

nvm ls-remote

To install multiple nodejs or single version :

nvm install v10.1.0

along with version 8 and 9 :

nvm install v8.11.1
nvm install v9.11.1

Stetting up Node.js Default Version :

nvm list

the output will be like this :

[root@mysterydata ~]# nvm list
        v8.11.1
        v9.11.1
->      v10.1.0
         system
default -> v10.1.0
node -> stable (-> v10.1.0) (default)
stable -> 10.1 (-> v10.1.0) (default)
iojs -> N/A (default)
lts/* -> lts/carbon (-> v8.11.1)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.14.2 (-> N/A)
lts/carbon -> v8.11.1

here “-> v10.1.0” is the default version, “-> ” is the default indicator

To change the Default nodejs version to version 8 run this command :

nvm use v8.11.1

then again run

nvm list

output :

[root@mysterydata ~]# nvm list
->      v8.11.1
        v9.11.1
        v10.1.0
         system
default -> v10.1.0
node -> stable (-> v10.1.0) (default)
stable -> 10.1 (-> v10.1.0) (default)
iojs -> N/A (default)
lts/* -> lts/carbon (-> v8.11.1)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.14.2 (-> N/A)
lts/carbon -> v8.11.1

you can also verify via this command :

node --version

To remove specific node version which is already installed run this command :

nvm list

Then run to remove the version :

nvm uninstall v9.11.1
or
nvm remove v9.11.1

If this post helps you in any way please consider a donation

Donate with PayPal :

md-donate

Donate with Paytm :

md-donate

You may also like

Leave a Reply

avatar
  Subscribe  
Notify of