Install Node.js (LTS) on Ubuntu debian based linux distribution

Get an up-to-date version of Node.js from the PPA (personal package archive) maintained by NodeSource.

curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get update
sudo apt-get install -y nodejs

Use Node.js Version Manager to manage multiple versions.

  • NVM works within your home directory.

  • Install multiple self-contained versions of Node.js

  • Access the latest versions of Node.js and retain and manage previous releases.

Download installation script from the Repository on GitHub.

curl -sL https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh -o install_nvm.sh

Install NVM

bash install_nvm.sh

source the .profile for the current session.

source  ~/.profile 

To Install nodejs LTS

nvm install 12.15.0

Verify Installation

nodejs -v
Output
v12.15.0
npm -v
Output
6.13.4

For the official documentation on how to install Nodejs visit:https://nodejs.org/en