How to install and upgrade Nodejs and npm in Ubuntu 20.04

lakshmi , Credit to  volkotech-solutions Sep 16

Built on Chrome's JavaScript, Node.js is a cross-platform JavaScript runtime environment intended for the server-side execution of JavaScript programs.

npm is the world's largest software registry and is the default package manager for Node.js. It is used to manage packages (collections of code that can be used in Node.js projects) and dependencies (libraries that a project needs in order to function). Node.js and npm are both built on Chrome's JavaScript engine and are available on multiple platforms.

Before, installing and upgrading any packages run the following commands to update the package index, and more:

$sudo apt update

$sudo apt -y upgrade

Installation of Nodejs and npm Process:

The installation process is rather simple. Run the following commands to install Node.js and npm :

$sudo apt install nodejs -y

$sudo apt install npm -y

Once completed the installation to check node and npm versions, use the following commands:

$node -v

$npm -v


insatll version node npm



Upgrade Nodejs and npm Process:

Some systems need to upgrade to the latest versions to run projects. The company NodeSource specialises in offering high-quality Node assistance for businesses. It keeps an APT repository with several Node.js versions. If your application needs a certain Node.js version, use this repository. For example, some projects need to install >=12 Nodejs version and use the following commands.

$curl -sL | sudo -E bash -
$sudo apt-get install -y nodejs

To upgrade to the latest versions of npm, use the following command:

$sudo npm install -g npm@latest

Once completed the process of upgrading to check node and npm versions, use the following commands:

$node -v
$npm -v


upgrade nodejs npm





If we get the following error then use the following command:

npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.

$sudo npm install uuid@latest