How to install and update Nodejs on Ubuntu 20.04 LTS

  1. Using Command
  2. Install Specific Nodejs version.
  3. Download tar.xz the file then install it.
  4. Update Nodejs:
  5. Uninstall NodeJs.
  6. Uninstall the previous version then install the specific version:

Step 1: Open your terminal or press Ctrl + Alt + T

Step 2: To install node.js use the following command:

sudo apt-get install nodejsnode -v  //Check Nodejs Version:or node –version

Step 4: In most cases, you’ll also want to also install npm,(Node.js package manager.). Install by the following command:

sudo apt install npm

Install Specific Nodejs version.

Install Specific Node.js version using the NodeSouce repository: the latest version of Node.js can be installed from the NodeSource repository. Follow the steps below to install the Node.js on your Ubuntu.

Step 1: Open your terminal or press Ctrl + Alt + T.

Step 2: Install curl:

sudo apt-get install curl

Step 3: Add Node.js PPA to the system.

curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs

Note: Here, we are installing node.js version 16, if you want to install version 14, you can replace setup_16.x with setup_14.x. or the following link.

Step 4: Install Node.js:

sudo apt-get install -y nodejs

Step 5: Check version:

node -v or node –versionnpm -v or npm –version

Congratulation, you have successfully installed Node.js and NPM on your Ubuntu machine.

Step 01: Download Node.js

sudo apt update  //update system repositoriessudo apt install xz-utils   // install the package xz-utils.sudo tar -xvf node-v16.17.0-linux-x64.tar.xz  //extract .tar.xz file.sudo cp -r node-v16.17.0-linux-x64/{bin,include,lib,share} /usr/export PATH=/usr/node-v16.17.0-linux-x64/bin:$PATH  //update Pathnode --version

Update Nodejs.

  1. Update npm
npm install npm@latest -gnpm cache clean -f  //clean npm cache
npm install -g n //install n Node’s version manager:
n latest //update node to the latest versionsudo n [version.number] //Install a specific version:orsudo n 16.04

Uninstall NodeJs:

sudo npm uninstall -g norsudo apt-get remove nodejsorsudo apt purge nodejs

Uninstall the previous version then install the specific version:

sudo apt-get purge --auto-remove nodejs
curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs

--

--

Senior Software Engineer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store