Introduction

Node.js is an open-source, cross-platform JavaScript runtime environment that executes JavaScript code outside a web browser. It allows developers to develop command-line tools and writing server-side code. Node.js unifying web application development using a single programming language rather than a different language for server-side and client-side code.

In this tutorial, we will see how to install Node.js on Ubuntu 20.04 using apt from default repositories.

Prerequisites

In this tutorial, I am assuming you are using Ubuntu 20.04 and you have a non-root account with sudo privileges set up on your system

Install Node.js using apt from default repositories

Default software repositories of Ubuntu 20.04 contain a version of Node.js. At the time of writing this tutorial the version in the repositories is 10.19.0, This version may not be the latest but it is stable and sufficient for getting started.

Before installing Node.js using apt we will run the following command to refresh our local package:

                    
                        sudo apt update
                    
                

Now we can install Node.js by run the following command:

                    
                        sudo apt install nodejs
                    
                

Once installation completed then we can verify it by check its version number:

                    
                        nodejs -v
                    
                
                    
                        Output
                        v10.19.0
                    
                

You may also want to install npm (Node.js Package Manager), you can also do this by using apt

                    
                        sudo apt install npm
                    
                

You can also check npm version by using the following command

                    
                        npm -v
                    
                
                    
                        Output
                        6.14.4
                    
                

Now you have successfully installed Node.js and npm using apt and Ubuntu default software repositories.