Update Node.js with NVM

There are different way of updating the Node.js, but the best way of updating Node.js on Ubundu server is to use NVM (Node Version Manager).

First update the package repository with the command:

sudo apt update

Now install NVM using curl command.

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

In order to verify the nvm version, close and reopen the terminal or run following command

source ~/.bashrc

Verify if you have successfully installed NVM:

nvm --version

In order to list the available releases run following command:

nvm ls-remote

To install the latest version, use the nvm command with the specific Node.js version:

nvm install [version number]
Installing node 14
Installing node 15

Since now we have installed two different versions of node 14 & 15, there is a nvm command that can be used to switch in between node versions.

node use 15
using node 15

That’s it, this is how you can manage and update multiple node versions, by the way same can be done on Mac IOS.

Author: Danyal
I'm working as programmer since 2002. Born, grew up, studied and worked in Pakistan now Im located in Denmark since 2006.