Node.js is a javascript platform, which allows web developers to create network applications easily and quickly. It runs on the server side that permits the server and desktop application to communicate through javascript.

In this article, we’ll show you how to install node.js on Ubuntu 19, Ubuntu 18 as well as on Ubuntu 16. Let us get into the section. You can also see how to install it on Windows, which we have updated earlier.

How to install nodejs in Ubuntu

There are 3 ways to install node.js on Ubuntu, the choice is yours and what you need for your computer.

Let we tell you one by one, first will go with Ubuntu repositories.

Using the official repositories of Ubundu 19

First open a terminal and proceed to update the system for the latest security patches.

sudo apt update && sudo apt upgrade

And then proceed to install node.js from the official repositories with:

sudo apt install nodejs

Most of the time you need your NPM package manager that is not installed by default with this method. For this, enter the below command

sudo apt install npm

Finally, we have to check the installed version of node.js through entering the command,

nodejs –v

Using PPA on Ubundu 16

It has latest versions of node.js that the official Ubundu repositories. Also, it allows you to choose between older version node.js v4.x and current version node.js v8.x.

You have to install the PPA to get access to its content.

cd ~

curl -sL https://deb.nodesource.com/setup_8.x -o nodesource_setup.sh

You can inspect the contents of this script with nano

nano nodesource_setup.sh

And run the script under sudo

sudo bash nodesource_setup.sh

Now the PPA will be added and updated automatically to your configuration as well as local package cache. Once you run the script from nodesource, you can install the node.js package by typing the below one,

sudo apt-get install nodejs

You can now check the installed version of node.js

nodejs –v

The nodejs package itself has nodejs binary ans npm, so no need to install npm separately. Execute the below mentioned command to verify the npm is installed:

npm –v

Additionally, you have to install the build-essential package to work on some npm packages.

sudo apt-get install build-essential

Installing node.js using NVM on Ubundu 18

To install node.js and npm through NVM on your Ubundu system, follow the below process;

Begin the process by downloading the NVM install script:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash

Don’t forget to verify that nvm was correctly installed by entering:

nvm –version

Now, we can install the current version of node.js, by the command:

nvm install node

After the above process, verify the nodejs version by typing

node –version

Leave a Reply

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