Table of Contents
Installing Node.js on Ubuntu is a simple procedure that requires only a few steps. Node.js is a popular JavaScript runtime based on Chrome’s V8 JavaScript engine that is commonly used for developing server-side applications. This tutorial will help you through the installation steps. Let’s have a look at the steps for install Node.js on Ubuntu.
Before you start, make sure you have the following:
– A version of Ubuntu, preferred version v18.04 or later
– A user account with sudo privileges.
– Basic Knowledge of Linux terminal commands.
– Internet access.
Many developers choose Node.js for web application development project, to do that following process needs to be followed. Before installing any new software, it’s always a good practice to update your system’s package index to ensure you have the latest versions of packages and their dependencies.
Open your terminal and run:
We’ll go over the two most prevalent methods: utilizing the NodeSource repository and NVM (Node Version Manager).
The easiest way to install Node.js on Ubuntu is using the official Ubuntu repository. To add it, run the following command:
This command fetches and executes the NodeSource installation script.
After adding the repository, install Node.js using:
This command installs both `node` and `npm` (Node Package Manager).
Verify the installation by checking the versions:
You should see output similar to:
V20.x.x
9.x.x
NVM is a script-based solution that lets you manage various active Node.js versions. This is very important when you need to move between Node.js versions.
Download and install NVM using the following command:
To start using NVM, you need to source your profile:
With NVM installed, you can install the latest LTS (Long Term Support) version of Node.js:
Check the installed versions of Node.js and npm:
node -v
npm -v
The output should reflect the versions you installed using NVM.
If you installed Node.js using NVM, you can easily switch between different versions:
Command:nvm ls
nvm use 14.17.0
nvm alias default 20.19.1
Congratulations! You have successfully installed Node.js on your Ubuntu machine. Whether you utilize the NodeSource repository or NVM, you now have an effective tool for developing scalable network applications.
sudo apt update && sudo apt install nodejs
sudo apt purge nodejs
nvm install <version>.
Rajan Shah
Technical Manager
Rajan Shah is a Technical Manager at Solution Analysts. He brings almost a decade of experience and a genuine passion for software development to his role. He’s a skilled problem solver with a keen eye for detail, his expertise spans in a diverse range of technologies including Ionic, Angular, Node.js, Flutter, and React Native, PHP, and iOS.
Get free consultation and let us know your project idea to turn
it into an amazing digital product.
2nd Floor, Sun Avenue One, Bhudarpura, Ayojan Nagar, Nr. Shyamal Cross Road, Ahmedabad, Gujarat-380006
Sales: +91 635-261-6164