Qadry
Linux SysAdmin From Egypt Highly motivated, optimistic always seeking for new challenges that makes me able to grow.

How to Install Latest NodeJS and NPM in Linux

Introduction

Nodejs is a lightweight and efficient JavaScript platform that 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.

NodeSource Node.js Binary Distributions

Note: You can find the NodeSource here

Installing NodeJs in RHEL, CentOS and Fedora

Installing NodeJS 16.x in RHEL, CentOS and Fedora

The latest version of Node.js and NPM is available from the official NodeSource Enterprise Linux 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.

To add the repository for the latest version of Node.js 16.x, use the following command as root or non-root.

Note: Check the Latest version of NodeJs

 As root
# curl -fsSL https://rpm.nodesource.com/setup_16.x | bash -

 No root privileges
# curl -fsSL https://rpm.nodesource.com/setup_16.x | sudo bash -

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

# yum -y install nodejs
OR
# dnf -y install nodejs

Installing NodeJS 14.x in RHEL, CentOS and Fedora

 As root
# curl -fsSL https://rpm.nodesource.com/setup_14.x | bash -

 No root privileges
# curl -fsSL https://rpm.nodesource.com/setup_14.x | sudo bash -

Installing NodeJS 12.x on RHEL, CentOS and Fedora

If you want to install NodeJS 12.x, add the following repository.

 As root
# curl -fsSL https://rpm.nodesource.com/setup_12.x | bash -

 No root privileges
# curl -fsSL https://rpm.nodesource.com/setup_12.x | sudo bash -

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.

# yum install gcc-c++ make
OR
# yum groupinstall 'Development Tools'

Installing NodeJs in Debian, Ubuntu and Linux Mint

Installing NodeJS 16.x in Debian, Ubuntu and Linux Mint

The latest version of Node.js and NPM is also available from the official NodeSource Enterprise Linux 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.

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

 Using Debian, as root
$ curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
$ apt-get install -y nodejs

Installing NodeJS 14.x in Debian, Ubuntu and Linux Mint

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

 Using Debian, as root
$ curl -fsSL https://deb.nodesource.com/setup_14.x | bash -
$ apt-get install -y nodejs

Installing NodeJS 12.x in Debian, Ubuntu and Linux Mint

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

 Using Debian, as root
$ curl -fsSL https://deb.nodesource.com/setup_12.x | bash -
$ apt-get install -y nodejs

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.

$ sudo apt-get install -y build-essential

Testing Latest Nodejs and NPM in Linux

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

On Debian, Ubuntu and Linux Mint

$ nodejs --version
$ npm --version

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

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

x