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 a skilled programmer specializing in Vue.js/Nuxt.js for front-end development and PHP Laravel for back-end solutions. I have a strong focus on API design and development, complemented by experience in web server setup and maintenance. My versatile expertise ensures seamless creation and maintenance of web applications, covering everything from intuitive user interfaces to robust server-side functionality. Passionate about coding and driven by a lifelong learning mindset, I invite you to explore more at danyal.dk.