How to Install Node.js on Ubuntu 18.04

Install Node.js on Ubuntu 18.04

In this tutorial we’ll learn how to install Node.js on Ubuntu 18.04. We will also install and configure its prerequisites. Node.js is a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications. Many of Node.ja modules are written in JavaScript, which simplifies development of applications using Node.js. Node.js nothing but a combination of the Runtime environment and JavaScript modules.

I recommend to use a minimal Ubuntu server setup as a basis for the tutorial, that can be a virtual or a root server image with an Ubuntu 18.04 LTS Bionic Beaver minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.

Install Node.js on Ubuntu 18.04

Step 1. First, ensure your system and apt package lists are fully up-to-date by running the following:

apt-get update -y
apt-get upgrade -y
apt-get install -y build-essential

Step 2. Installing Node.js on Ubuntu 18.04.

First, download and execute the Node.js 10.x installer:

curl -sL | sudo -E bash -

Run the following command to make sure that you install the latest version of Node.js:

apt update
apt install nodejs

Also you can install npm (Node.js package manager) to install modules and packages. To install npm, run the command below:

apt install npm

Step 3. Verify Node.js Installation.

Check if the installation was successful, by printing the Node.js and npm versions:

$ node --version

$ npm -v

Congratulation’s! You have successfully install and configured Node.js on your Ubuntu 18.04 server. Thanks for using this tutorial installing Node.js on Ubuntu 18.04 LTS (Bionic Beaver) system.