Site icon DesignLinux

How to Install Latest NodeJS and NPM in Linux

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 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.

On this page:
  1. How to Install Node.js 14 in CentOS, RHEL, and Fedora
  2. How to Install Node.js 14 in Debian, Ubuntu and Linux Mint

How to Install Node.js 14 in CentOS, RHEL, 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.

Important: If you are running an older release of RHEL 6 or CentOS 6, you might want to read about running Node.js on older distros.

Installing NodeJS 14.x in RHEL, CentOS and Fedora

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

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

-------------- A user with root privileges  --------------
$ curl -sL 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 user -------------- 
# curl -sL https://rpm.nodesource.com/setup_12.x | bash -

-------------- A user with root privileges  --------------
$ curl -sL https://rpm.nodesource.com/setup_12.x | sudo bash -

Installing NodeJS 10.x on RHEL, CentOS and Fedora

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

-------------- As root user -------------- 
# curl -sL https://rpm.nodesource.com/setup_10.x | bash -

-------------- A user with root privileges  --------------
$ curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash -
Adding Node.js Repository in CentOS

Adding Node.js Repository in CentOS

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

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

Install NodeJS in CentOS

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'

Install Development Tools in CentOS

How to Install Node.js 14 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.

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

------- On Ubuntu and Linux Mint ------- 
$ curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
$ sudo apt-get install -y nodejs

------- On Debian ------- 
# curl -sL https://deb.nodesource.com/setup_14.x | bash -
# apt-get install -y nodejs

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

------- On Ubuntu and Linux Mint ------- 
$ curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
$ sudo apt-get install -y nodejs

------- On Debian ------- 
# curl -sL https://deb.nodesource.com/setup_12.x | bash -
# apt-get install -y nodejs

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

------- On Ubuntu and Linux Mint ------- 
$ curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
$ sudo apt-get install -y nodejs

------- On Debian ------- 
# curl -sL https://deb.nodesource.com/setup_10.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

Check NodeJS Version in CentOS

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. I hope this guide was helpful to you and always remember to stay connected to Tecmint.

Sharing is Caring…
Share on FacebookShare on TwitterShare on LinkedinShare on Reddit
Exit mobile version