Install Latest Nodejs and NPM Version in Linux Systems

In this guide, we shall take a look at how you can install the latest version of Nodejs and NPM in RHEL, CentOS, Fedora, Debian and Ubuntu distributions.

Read Also: NVM – Install and Manage Multiple Node.js Versions in Linux

Nodejs is a lightweight and efficient JavaScript platform which is built based on Chrome’s V8 JavaScript engine and NPM is a default NodeJS package manager. You can use it to build scalable network applications.

Step 1: Adding NodeSource Repository

The latest version of Node.js and NPM is available from the official NodeSource Enterprise Linux, Fedora, Debian and Ubuntu binary distributions repository, which is maintained by the Nodejs website and you will need to add it to your system to be able to install the latest Nodejs and NPM packages.

Important: Under RHEL 5 and CentOS 5, the Node.js packages are depend on the EPEL repository, so the script will check and give instructions if incase it’s not installed.

To add the repository for the latest version of Node.js, use the following command as root..

On RHEL, CentOS and Fedora

---------- Install Node.js v11.x ---------- 
$ curl -sL | bash -

---------- Install Node.js v10.x ----------
$ curl -sL | bash -
Sample Output
## Installing the NodeSource Node.js 11.x repo...

## Inspecting system...

+ rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release || rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release
+ uname -m

## Confirming "el7-x86_64" is supported...

+ curl -sLf -o /dev/null ''

## Downloading release setup RPM...

+ mktemp
+ curl -sL -o '/tmp/tmp.AhnE1gAaMU' ''

## Installing release setup RPM...

+ rpm -i --nosignature --force '/tmp/tmp.AhnE1gAaMU'

## Cleaning up...

+ rm -f '/tmp/tmp.AhnE1gAaMU'

## Checking for existing installations...

+ rpm -qa 'node|npm' | grep -v nodesource

## Run `sudo yum install -y nodejs` to install Node.js 11.x and npm.
## You may also need development tools to build native addons:
     sudo yum install gcc-c++ make
## To install the Yarn package manager, run:
     curl -sL | sudo tee /etc/yum.repos.d/yarn.repo
     sudo yum install yarn

On Debian, Ubuntu and Linux Mint

---------- Install Node.js v11.x ---------- 
$ curl -sL | sudo -E bash -

---------- Install Node.js v10.x ----------
$ curl -sL | sudo -E bash -
Sample Output
## Installing the NodeSource Node.js v11.x repo...

## Populating apt-get cache...

+ apt-get update
Get:1 yakkety-security InRelease [102 kB]
Get:2 yakkety InRelease [247 kB]
Get:3 yakkety-security/main i386 Packages [109 kB]
Get:4 yakkety-updates InRelease [102 kB]
Get:5 yakkety-security/main amd64 Packages [112 kB]
Get:6 yakkety-security/universe amd64 Packages [56.5 kB]
Get:7 yakkety-security/universe i386 Packages [54.3 kB]
Get:8 yakkety-backports InRelease [102 kB]
Get:9 yakkety-security/universe Translation-en [35.2 kB]
Get:10 yakkety-updates/main amd64 Packages [224 kB]
Get:11 yakkety-updates/main i386 Packages [221 kB]
Get:12 yakkety-updates/main Translation-en [100.0 kB]
Get:13 yakkety-updates/universe amd64 Packages [144 kB]
Get:14 yakkety-updates/universe i386 Packages [142 kB]
Get:15 yakkety-updates/universe Translation-en [76.2 kB]                                                                                                 
Get:16 yakkety-updates/multiverse amd64 Packages [4,632 B]                                                                                               
Get:17 yakkety-updates/multiverse Translation-en [2,252 B]                                                                                               
Fetched 1,835 kB in 7s (261 kB/s)                                                                                                                                                            
Reading package lists... Done

## Confirming "yakkety" is supported...

+ curl -sLf -o /dev/null ''

## Adding the NodeSource signing key to your keyring...

+ curl -s | apt-key add -

## Creating apt sources list file for the NodeSource Node.js v11.x repo...

+ echo 'deb yakkety main' > /etc/apt/sources.list.d/nodesource.list
+ echo 'deb-src yakkety main' >> /etc/apt/sources.list.d/nodesource.list

## Running `apt-get update` for you...

+ apt-get update
Get:1 yakkety-security InRelease [102 kB]
Get:2 yakkety InRelease [247 kB]     
Get:3 yakkety-updates InRelease [102 kB]
Get:4 yakkety InRelease [3,915 B]
Get:5 yakkety-backports InRelease [102 kB]
Get:6 yakkety/main Sources [765 B]
Get:7 yakkety/main i386 Packages [961 B]
Get:8 yakkety/main amd64 Packages [964 B]
Fetched 560 kB in 2s (215 kB/s)   
Reading package lists... Done

## Run `apt-get install nodejs` (as root) to install Node.js v11.x and npm

Step 2: Install Latest Nodejs and NPM

Next, you can now install Nodejs and NPM on your system using the command below:

On RHEL, CentOS and Fedora

# yum -y install nodejs
# dnf -y install nodejs   [On Fedora 22+ versions]
Sample Output
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base:
 * elrepo:
 * epel:
 * extras:
 * updates:
Resolving Dependencies
--> Running transaction check
---> Package nodejs.x86_64 2:11.3.0-1nodesource will be installed
--> Finished Dependency Resolution

Dependencies Resolved

 Package                                  Arch                                     Version                                                  Repository                                    Size
 nodejs                                   x86_64                                   2:11.3.0-1nodesource                                     nodesource                                    18 M

Transaction Summary
Install  1 Package

Total download size: 18 M
Installed size: 54 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/nodesource/packages/nodejs-11.3.0-1nodesource.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 34fa74dd: NOKEY===========-] 2.8 MB/s |  18 MB  00:00:00 ETA 
Public key for nodejs-11.3.0-1nodesource.x86_64.rpm is not installed
nodejs-11.3.0-1nodesource.x86_64.rpm                                                                                                                                    |  18 MB  00:00:05     
Retrieving key from file:///etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL
Importing GPG key 0x34FA74DD:
 Userid     : "NodeSource <[email protected]>"
 Fingerprint: 2e55 207a 95d9 944b 0cc9 3261 5ddb e8d4 34fa 74dd
 Package    : nodesource-release-el7-1.noarch (installed)
 From       : /etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : 2:nodejs-11.3.0-1nodesource.x86_64                                                                                                                                          1/1 
  Verifying  : 2:nodejs-11.3.0-1nodesource.x86_64                                                                                                                                          1/1 

  nodejs.x86_64 2:11.3.0-1nodesource                                                                                                                                                           


On Debian, Ubuntu and Linux Mint

$ sudo apt-get install -y nodejs
Sample Output
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 106 not upgraded.
Need to get 10.3 MB of archives.
After this operation, 52.1 MB of additional disk space will be used.
Get:1 yakkety/main amd64 nodejs amd64 11.3.0-1nodesource1~yakkety1 [10.3 MB]
Fetched 10.3 MB in 45s (224 kB/s)                                                                                                   
Selecting previously unselected package nodejs.
(Reading database ... 65830 files and directories currently installed.)
Preparing to unpack .../nodejs_11.3.0-1nodesource1~yakkety1_amd64.deb ...
Unpacking nodejs (11.3.0-1nodesource1~yakkety1) ...
Setting up nodejs (11.3.0-1nodesource1~yakkety1) ...
Processing triggers for man-db (2.7.5-1) ...

Optional: There are development tools such as gcc-c++ and make that you need to have on your system, in order to build native addons from npm.

------- On RHEL, CentOS and Fedora -------
# yum install gcc-c++ make

------- On Debian, Ubuntu and Linux Mint -------
$ sudo apt-get install -y build-essential

Step 3: Testing Latest Nodejs and NPM

To have a simple test of nodejs and NPM, you can just check the versions installed on your system by using the following commands:

On RHEL, CentOS and Fedora

# node --version
# npm --version
CentOS 7- Check Nodejs and NPM Version

CentOS 7 – Check Nodejs and NPM Version

On Debian, Ubuntu and Linux Mint

$ nodejs --version
$ npm --version
Ubuntu 15.10 - Check Nodejs and NPM Version

Ubuntu 15.10 – Check Nodejs and NPM Version

That is it, Nodejs and NPM are now installed and ready for use on your system.

I believe these were easy and simple steps to follow but in case of problems you faced, you can let us know and we find ways of helping you. Hope this guide was helpful to you and always remember to stay connected to Tecmint.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Aaron Kili

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide
The Complete Linux System Administrator Bundle
Become an Ethical Hacker Bonus Bundle

You may also like...

2 Responses

  1. Siraj says:

    It’s not latest, you have added setup_11.x and setup_10.x but it is installing 6.x.

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.