Install NPM on Ubuntu 18.04 Bionic Beaver Linux

Objective

The objective of this article is to install NPM on Ubuntu 18.04 Bionic Beaver. NPM is the package manager for JavaScript.

Operating System and Software Versions

  • Operating System: – Ubuntu 18.04 Bionic Beaver
  • Software: – 3.5.2 or higher

Requirements

Privileged access to your Ubuntu System as root or via sudo command is required.

Difficulty

EASY

Conventions

  • # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
  • $ – requires given linux commands to be executed as a regular non-privileged user

Instructions

Install NPM on Ubuntu

The following linux command will install NPM on the Ubuntu 18.04 system. It is also recommended to install NPM alongside with the build-essential package in case that NPM encounters a source package during module installations:

$ sudo apt install npm build-essential

Check for NPM version:

$ npm --version
3.5.2


Use NPM to install JavaScript module

To search all available modules with NPM enter:

$ npm search KEYWORD

To perform a module installation with NPM run:

$ npm install MODULE-NAME

To install a JavaScript module directly from GIT repository execute NPM with the URL of the actual module you wish to install.

For example the bellow command will install the express module from its home git repository:

$ npm install git+https://git@github.com/visionmedia/express.git
OR with SHH access
$ npm install git+ssh://git@github.com/visionmedia/express.git