How to Install Node.js on Ubuntu 20.04 Focal Fossa


In this article, we will have explained the necessary steps to install and configure Node.js on Ubuntu 20.04 LTS. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Node.js is an open-source cross-platform JavaScript run-time environment that allows server-side execution of JavaScript code which simply means that you can run JavaScript code on your machine as a standalone application, free of any web browser.

The Node.js framework is available for a variety of operating systems right from Windows to Ubuntu and OS X. Once the Node.js framework is installed, you can start building your first Node.js applications. Node.js also has the ability to embedded external functionality or extended functionality by making use of custom modules.

Install Node.js on Ubuntu 20.04

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

Step 2. Install Node.js on the Ubuntu system.

  • Installing Node.js and npm from Source

Download and execute the NodeSource installation script:

Once the NodeSource repository is enabled, install Node.js and npm:

  • Installing Node.js and npm from the Ubuntu repositories:

You can install Node.js and npm from the standard Ubuntu repositories. We will use apt the command to install the stable default Node.js version from the Ubuntu repository:

Verify the node.js version, type:

NPM doesn’t ship with Node so you’ll need to separately install it. Run the following command:

  • Install Node.js using NVM.

Visit the nvm GitHub repository page and install the nvm script:

The script will clone the project’s repository from Github to the ~/.nvm directory, Once the script, is in your PATH, verify that nvm was properly installed by typing:

To install the latest available version of Node.js, run:

Check the version of Node.js and NPM using the following command:

That’s all you need to do to install Node.js on Ubuntu 20.04 Focal Fossa. I hope you find this quick tip helpful. If you have questions or suggestions, feel free to leave a comment below.