How to Install Node.js and NPM on Ubuntu


how to install Node.js on Ubuntu 18.04. This method works for local Linux machines and virtual private servers. We’ll cover two ways. You will also learn how to remove the feature.

What is Node.js

Node.js is one of the most popular web technologies today. It is used by many developers to increase the functionality of a web application. Some of the largest companies use it. That should give you an idea of its potential.

Simply put, Node.js is a server-side execution environment that allows JavaScript to run without the client. Node.js is open source and cross-platform, which makes it ideal for different projects – from education to business.

At the time of writing, the latest stable version of Node.js is 11.10.0. However, the recommended version for most users is 10.15.1 as it is a long-term supported version.

There are several ways to install Node.js, here we will show you the two simplest and most efficient ones.

Before you start, you must have access to your server and be able to execute commands using sudo

Install Node.js and NPM from Ubuntu official repository

The easiest and fastest way to install Node.js on a server with Ubuntu 18.04 is through the official distribution repository.

First, connect to your server using ssh.

ssh username@server_ip_address

If you are running a system with Ubuntu, just open a terminal emulator from the main menu.

Once you’re connected refresh the APT cache. To do this, execute the following command

sudo apt update

With this, we make sure that the repositories are synchronized and the system can safely download what is stored in them.

After that, you can install Node.js by running the following command.

sudo apt install nodejs

After entering your password, the installation process will begin.

You can also install NPM, which is the node.js package manager.

sudo apt install npm

Finally, check the installed version. To do so, run the following command

nodejs -v
step3 version1
this pic from google

This is the easiest way to install Node.js onto a Linux machine or Linux based VPS.

To remove Node.js, run this command

sudo apt remove nodejs

Install a specific version of Node.js using NVM

There is another way to install Node.js on a server with Ubuntu 18.04. Using an NVM (Node Version Manager), we can choose a specific version to install. It’s great if you want to use an LTS version or just the latest version available.

First, download NVM using wget. If you are not sure you have wget, run this command.

sudo apt install wget

Now, run this command.

wget -qO- | bash

The next step is to allow NVM to be used from your user’s bash profile by running this command

source ~/.profile

Now, you can use NVM to show all the versions of Node.js available to install.

nvm ls-remote
nvm ls remote

Feel free to choose the one you want. For stability and support we recommend version 10.15.1. To do it, run this command

nvm install 10.15.1

You can check if the installation was successful by checking the version of Node.js. To do this execute

node -v

If you want to uninstall Node.js, and installed it with this method, deactivate it first.

nvm deactivate

Then, uninstall Node.js.

nvm uninstall v10.15.1

Node.js is a very useful technology for developing web applications. Installing it on a server with Ubuntu 18.04 is simple and we     have shown you two ways to do it.


  1. Everything is very open with a very clear explanation of the challenges. It was definitely informative. Your website is extremely helpful. Thank you for sharing!


Please enter your comment!
Please enter your name here