Table of Contents
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.
- Installing node.js using the official Ubuntu repositories
- Installing using PPA
- Using NVM
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.
And then proceed to install node.js from the official repositories with:
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
Finally, we have to check the installed version of node.js through entering the command,
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.
You can inspect the contents of this script with nano
And run the script under sudo
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,
You can now check the installed version of node.js
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:
Additionally, you have to install the build-essential package to work on some npm packages.
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:
Don’t forget to verify that nvm was correctly installed by entering:
Now, we can install the current version of node.js, by the command:
After the above process, verify the nodejs version by typing