JavaScript is the most popular programming language among software developers, for three years in a row, according to the yearly survey conducted by Stack Overflow.

This guide will take a look at how to install Node.js, one of the core technologies that has popularised the JavaScript language. Node.js is a JavaScript runtime environment, that allows you to create server-side or backend JavaScript applications.

Why Use Node.js?

Because of the popularity of JavaScript, it is most likely that you have come across Node.js as part of your software development workflow.

Prior to Node.js, JavaScript code could only run in the web browser. Some of the reasons why you might want to use Node.js include:

  • The ability to run and compile JavaScript code as you develop the application.
  • The ability to run TypeScript-based frameworks such as Angular.
  • Node.js allows you to create server-side or desktop applications written in JavaScript.

To top it all, Node.js is easy to set up, highly scalable, very robust, and well documented.

How to Install Node.js on Ubuntu

Without further ado, here's how you can easily and quickly install Node.js on Ubuntu.

First, update your system's package repositories.

        sudo apt update
    

Then, install Node.js via APT using the following command:

        sudo apt install nodejs
    

In addition to Node.js, you should also install npm on Ubuntu, which is the software that facilitates and handles the installation of Node packages, modules, and their dependencies.

        sudo apt install npm
    

Related: What's the Difference Between APT and dpkg?

Verifying the Node.js Installation

To check if everything has been installed successfully, you can query for the version of Node.js you just installed.

        node -v
    
command ouput showing the version of node.js in use

Alternative Ways of Installing Node.js

This guide has shown you how to easily and quickly install Node.js on Ubuntu using the APT package manager.

As with most things on Linux, there are several other options for installing Node.js and npm depending on your needs or requirements.