This guide walks you through the the installation and configuration of Node.JS on Ubuntu 20.04. In the next section, We will discuss some of the most popular Node.JS modules and tools you can use to create your next project. Stay tuned for that.
Let's get started!
Ensure you have the following to follow along.
- Ubuntu 20.04 installed on your system
- User with sudo privileges
- Internet connection
- Access to the terminal.
Updating the apt manager
We will use the apt package manager to install Node JS.
First, Update the apt package index with the following command:
sudo apt update
The next thing is to upgrade the repository. Run the following command:
sudo apt upgrade -y
Node JS installation
We now install Node JS and
npm (Node JS package manager) with the following command.
sudo apt install nodejs npm
Press "y" to continue when prompted.
This command will install Node and the
npm package manager, which we will use to install Node JS modules.
Verify the Node JS version installed
After the installation, verify that Node.JS and
npm are successfully installed by running the following commands:
The node version installed in my system is v10.19.0. Yours will probably differ, but this confirms that Node is successfully installed on your machine.
You can verify that
npm is installed on your system with the following command.
Working with Node JS
Now that we have installed Node JS on our system, we can start writing our first program.
Create a new file named geekbits.js using your favorite text editor and add the following code:
Save the file then exit the editor. Run the program with the following command:
Make sure you are in the right directory i.e., where the file is saved.
The output "Hello, world!" should be printed on the console.
Salute! You have written your first Node JS program
There are many popular modules and tools available for Node.JS development. So stay tuned for this tutorial.
In this guide, we have successfully installed and configured Node together with its package manager (
npm) on Ubuntu 20.04.