Installing Multiple Versions Of NodeJs Versions On Your Linux System
Today, I'm going to show you how to install and manage multiple versions of NodeJs on your linux system.
We are going to use NVM to install and manage multiple versions of NodeJs on same system. So we need to install NVM first.. To install it just copy paste the below command.
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
The above script will download and install NVM on your Linux box.. Now run the below command to activate it in current terminal session or just close and open your current terminal session.
source ~/.bashrc
Now just check the NVM installation with following command..
nvm --version
It should print version like one shown below..
shivaraj@shivaraj-A14RM0E:~/articles-now$ nvm --version
0.33.8
shivaraj@shivaraj-A14RM0E:~/articles-now$
Installing NodeJs with NVM
Now we are going to see how to install the latest version of Nodejs using NVM..
Just Run the below command to install latest version of nodejs in your system
nvm install node
This will produce output like one shown below.. on successful installation..
shivaraj@shivaraj-A14RM0E:~/articles-now$ nvm install node
Downloading and installing node v10.5.0...
Downloading https://nodejs.org/dist/v10.5.0/node-v10.5.0-linux-x64.tar.xz...
######################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v10.5.0 (npm v6.1.0)
You can check the version of node installed with node -v
and npm with npm -v
shivaraj@shivaraj-A14RM0E:~/articles-now$ node -v
v10.5.0
shivaraj@shivaraj-A14RM0E:~/articles-now$ npm -v
6.1.0
shivaraj@shivaraj-A14RM0E:~/articles-now$
You can install particular version of NodeJs with npm install version-number
. For example to install NodeJs version 8 you can use nvm install 8
shivaraj@shivaraj-A14RM0E:~/articles-now$ nvm install 8
Downloading and installing node v8.11.3...
Downloading https://nodejs.org/dist/v8.11.3/node-v8.11.3-linux-x64.tar.xz...
######################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v8.11.3 (npm v5.6.0)
shivaraj@shivaraj-A14RM0E:~/articles-now$
To check the different versions of NodeJs installed in your local system.. run the following command
nvm ls
shivaraj@shivaraj-A14RM0E:~/articles-now$ nvm ls
v8.9.4
-> v8.11.3
v9.4.0
v10.5.0
default -> 8 (-> v8.11.3)
node -> stable (-> v10.5.0) (default)
stable -> 10.5 (-> v10.5.0) (default)
iojs -> N/A (default)
lts/* -> lts/carbon (-> v8.11.3)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.14.3 (-> N/A)
lts/carbon -> v8.11.3
shivaraj@shivaraj-A14RM0E:~/articles-now$
To switch from one version to other you can use following command.. nvm use version number
. for example to use Node Version 10 you have to run nvm use 10
shivaraj@shivaraj-A14RM0E:~/articles-now$ nvm use 10
Now using node v10.5.0 (npm v6.1.0)
shivaraj@shivaraj-A14RM0E:~/articles-now$
If you want to set some node version as default version to use ... you can set it with following command.. nvm alias default node-version
.. if you want to set the node version 8 as default one you can set it by running this command nvm alias default 8
shivaraj@shivaraj-A14RM0E:~/articles-now$ nvm alias default 8
default -> 8 (-> v8.11.3)
shivaraj@shivaraj-A14RM0E:~/articles-now$
Here is the video for above tutorial...
That's it for now.. Thank You.. If you like don't forget to share it guys..
You can follow us on fb.com/opensourceinside and also subscribe our channel on Youtube..