How to install npm on RHEL 8 / CentOS 8

NPM is a javascript package manager for the Node JavaScript platform. The objective of this article is to install NPM on RHEL 8 / CentOS 8. To install NPM on RHEL 8 / CentOS 8 we will use the dnf install command.

In this tutorial you will learn:

  • How to install NPM on Rhel 8.
  • How to search for modules using NPM.
  • How to install modules using NPM.
  • How to install modules form a Git repository.

Installing NPM on Redhat 8.

Installing NPM on Redhat 8.

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System RHEL 8 / CentOS 8
Software npm 6.4.1 or higher
Other Privileged access to your Linux system as root or via the sudo command.
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

How to install npm on RHEL 8 / CentOS 8 step by step instructions



  1. Use the dnf command to install npm package:
    # dnf install npm
    
  2. Check npm version to confirm the Npm installation:
    # npm --version
    6.4.1
    
  3. Install modules using the npm command.

    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