How To Install Multiple Node Versions On Ubuntu 20.04

Uğur Emirmustafaoğlu

Uğur Emirmustafaoğlu /

2 min read ⏲––– views

linux
node
npm
fedora

I am sure you face some situations that your application requires different version of Node. There is a tool called nvm (Node Version Manager), which allows you to install multiple Node version and jump between them easily. Today we will install it on Ubuntu 20.04, my new favourite Linux distro.

Prerequisites

  • Your favourite terminal application
  • curl - command line tool and library for transferring data with URLs.
  • sudo privileges

Let's Start!

This command will fetch the installer script with curl and run it for you. It will create .nvm folder in your home directory and it will put all the necessary files there for you.

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

In order to activate the changes close your terminal and re-open it. Let's check if it is installed by asking for the version number of it.

nvm -v

How to install a specific node version with NVM?

You can install node easily by typing nvm install node. This will install the latest version of node. Let's say your application runs on node 14.17.2. It is just as easy as typing:

nvm install 14.17.2

After the installation, you will be using that version. You can check which version you are running by typing:

nvm current

In order to use an installed version of node you can use this command:

nvm use <version number>

If you would like to learn more about nvm, you can always check the help page by typing:

nvm --help

or you can visit their github repo.

Conclusion

And that's it! You have learned how to install a specific node version on Ubuntu 20.04. Actually this tutorial doesn't include any Ubuntu specific customisation, which means you can follow this tutorial on any Linux distribution.

Have a nice day and follow me on Twitter.

0
0
0
0
0