How to Install NPM & Node js on Ubuntu 19.04

How to Install NPM & Node js on Ubuntu 19.04

To install Node.js and NPM on latest Ubuntu 19.04, we don’t need to add any kind PPA (personal package manager), however, there is an official PPA for Node.js that we can use to install latest versions of Nodejs & NPM on Ubuntu such as 19.04, 18.04 LTS, 16.04 LTS (Trusty Tahr) and 14.04 LTS (Xenial Xerus) Linux servers.

Node.js on Ubuntu gives a way to write server-side scripting. It is an open source Javascript cross-platform that executes the Javascript outside the browsers. It uses an NPM package manager to fetch different packages and modules for function extensions of the app developed on Node.js. To install Node.js and NPM on latest Ubuntu 19.04, we don’t need to add any kind PPA (personal package manager), however, there is an official PPA for Node.js that we can use to install latest versions of Nodejs & NPM on Ubuntu such as 19.04, 18.04 LTS, 16.04 LTS (Trusty Tahr) and 14.04 LTS (Xenial Xerus) Linux servers.

Install NPM & Node js on Ubuntu 19.04

Step 1: Offical PPA repository for Node.js

Open the command terminal on Ubuntu Linux and add the official repository for downloading and installing the NPM and Node.js. The Long term stable release of Node.js is 10.15.3 LTS and a current stable release is 11.14.0. By default, the user will get the long term stable version 10.15.3 on Ubuntu 19.04, however, we can install the current version using Node.js PPA.

For long term version, we don’t need to add the repo, just type the commands:

sudo apt-get install nodejs
Sudo apt-get install npm

Note: Without adding latest PPA manually, the user will get Node.js LTS 10.x version from Ubuntu 19.04 repo. So to get a current 11.X release, add the below official repo.

For latest Node.js version 11.x use this PPA:


sudo apt install curl
curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash -

For 10.X version Node.js use this repo.

sudo apt install curl
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -

Note: As we are using 11.x repo on Ubuntu 19.04, here.

Step 2: Update your system.

After adding the Node.js Repo run the system update command:


sudo apt-get update

Step 3: Command to install the Node.js on Ubuntu 19.04

Note: Without PPA we have to install Node and NPM using two different commands, however, those are using the PPA will get both Nodejs and NPM using single below command:

sudo apt-get install nodejs

Step 4 Install NPM on Ubuntu 190.4 via command

After installing the Node.js, use this command to set up the NPM package manager on Ubuntu 19.04


sudo apt-get install npm

Step 5: Check the installed Node and NPM version on Ubuntu

Versions on Ubuntu 19.04 without using PPA- LTS versions

To check the Node version on Ubuntu, the command is:


node --version

To check the NPM version, the command is:

npm -v 

This is image title

After using the Latest Node.js PPA repo, the latest version–

This is image title

Step 6: Command to upgrade NVM and Node (optional)

Note: If you are using the PPA, simply run sudo apt update

First, update npm,

sudo npm update

npm install -g [email protected]

Then update node to the next version,


npm install -g [email protected]  
or
npm install -g [email protected]

Step 7: Command to select previous version npm on Ubuntu 19.04 (optional)

Note: Run these commands, if you know what are you doing otherwise it could mess your NPm setup.

Command to see the older available version on Ubuntu

npm view npm versions --json

Command to select the previous NPM version

npm i -g [email protected]

For example, I want to select the older 5.8.0 version then the command will be:

npm i -g [email protected]

or


sudo npm cache clean -f
sudo npm install -g n
sudo n 5.8.0

Step 8: Let’s install something using NPM (options step):

For example, we want to install Angular CLI using NPM then the commands will like this:

For locally:

npm install @angular/cli

Fo Globally: -g syntax refers to the global

npm install -g @angular/cli

Step 9: Uninstall node js ubuntu

The command to uninstall node.js on Ubuntu is:

To uninstall Nodejs

sudo apt-get remove nodejs

To uninstall NPM

sudo apt-get remove npm

Completely remove NPM related entries:

sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/npm*

Thanks for reading

nodejs Ubuntu

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How to Install Microsoft Teams on Ubuntu 20.04

In this tutorial, we will show you how to install Microsoft Teams on Ubuntu 20.04 machine. we can install teams using Debian installer file or by adding microsoft repository.

How to Install NodeJS on Ubuntu 19.04

In this tutorial, you will learn how to install Node onto Ubuntu 19.04 Disco Dingo. We will cover installation from the default repositories and, for those wanting more recent releases, how to install from the NodeSource repositories.

Hire NodeJs Developer

Looking to build dynamic, extensively featured, and full-fledged web applications? **[Hire NodeJs Developer](https://hourlydeveloper.io/hire-dedicated-node-js-developer/ "Hire NodeJs Developer")** to create a real-time, faster, and scalable...

How to upgrade NodeJS version in Ubuntu?

CrowdforThink : Blog -How to upgrade NodeJS version in Ubuntu?In this post i want to share about how to update node version in ubuntu OS. I would like to share this post because i try lot to update my node js package. When i install 0.10.25 nodejs but i want to update nodejs current latest version. At that time i did try lot to upgrade but i can't update my node.

Hire Nodejs Developer

Looking to **hire NodeJS Developer**[https://www.dataeximit.com/node-js-development/](https://www.dataeximit.com/node-js-development/ "https://www.dataeximit.com/node-js-development/") to build a perfect back-end to your website or...