Install Node Version Manager

Grab the script.

wget --quiet https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh --output-document /tmp/nvm_install.sh

Make the script executable, check it’s safe, and if happy then run it.

chmod u+x /tmp/nvm_install.sh
bash /tmp/nvm_install.sh

Restart your terminal session, or just source ~/.bashrc.

Now, check the available versions to install using nvm.

$ nvm ls-remote | grep "Latest LTS"
...
         v4.9.1   (Latest LTS: Argon)
        v6.17.1   (Latest LTS: Boron)
        v8.17.0   (Latest LTS: Carbon)
       v10.21.0   (Latest LTS: Dubnium)
       v12.18.2   (Latest LTS: Erbium)

Install the required version, in this case the latest LTS version.

nvm install v12.18.2

Check the version of node.

$ node -v
v12.15.0

nvm should switch to the most recently installed version. You can tell nvm to use another version you have installed though.

nvm use v12.15.0

Check any versions you have installed.

nvm ls

You can default any version downloaded.

nvm alias default v12.15.0