Continue reading "How to Install Node.js on Ubuntu"

"> How to Install Node.js on Ubuntu

How to Install Node.js on Ubuntu

Aug 2nd, 2024

How to Install Node.js on Ubuntu

 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. 

Prerequisites

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. 

Step 1: Update Your System 

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: 

sudo apt updatesudo apt upgrade -y 

Step 2: Install Node.js on Ubuntu

We’ll go over the two most prevalent methods: utilizing the NodeSource repository and NVM (Node Version Manager). 

Method 1: Using the NodeSource Repository 

  • Add NodeSource Repository 

The easiest way to install Node.js on Ubuntu is using the official Ubuntu repository. To add it, run the following command:

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash – 

This command fetches and executes the NodeSource installation script. 

  • Install Node.js on Ubuntu

After adding the repository, install Node.js using: 

sudo apt install -y nodejs 

This command installs both `node` and `npm` (Node Package Manager). 

  • Verify Installation 

Verify the installation by checking the versions: 

node -v

node -v

npm -v 

nvm -v

You should see output similar to: 

V20.x.x

9.x.x 

Method 2: Using NVM (Node Version Manager) 

  • Install NVM 

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: 

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash 

To start using NVM, you need to source your profile: 

source ~/.bashrc 
  • Install Node.js on Ubuntu with NVM 

With NVM installed, you can install the latest LTS (Long Term Support) version of Node.js: 

nvm install –lts 
  • Verify Installation

Check the installed versions of Node.js and npm: 

node -v
node -v
npm -v
nvm -v

The output should reflect the versions you installed using NVM. 

Step 3: Manage Node.js Versions (Optional) 

If you installed Node.js using NVM, you can easily switch between different versions: 

  • List Installed Versions 

Command:nvm ls 

  • Use a Specific Version 

nvm use 14.17.0 

  • Set Default Version 

nvm alias default 20.19.1 

Conclusion 

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.

Additional Tips

  • To update Node.js run the following command 

sudo apt update && sudo apt install nodejs

  • To uninstall Node.js, run the following command

sudo apt purge nodejs

  • To install specific version of Node.js using NVM, run the following command

nvm install <version>.  

Profile Picture

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.

Comments are closed.

Let's Discuss Your Project

Get free consultation and let us know your project idea to turn
it into an amazing digital product.

Let’s talk

NEWS & BLOG

Related Blogs

How to Choose the Best Node.js Development Company? A Complete Guide 2024

Android Apps Oct 23rd, 2024

How to Choose the Best Node.js Development Company? A C...

Read more
How Long Does It Take to Develop a Mobile App?

AI Oct 21st, 2024

How Long Does It Take to Develop a Mobile App?...

Read more
NodeJs – Write Test case and Code Coverage using SonarQube

Node.js Oct 14th, 2024

NodeJs – Write Test case and Code Coverage using ...

Read more

INQUIRY

Let's get in touch

UNITED STATES

4411 Suwanee Dam road,
Bld. 300 Ste. 350
Suwanee GA, 30024

Sales: +1 (415) 230 0051

UNITED KINGDOM

Kemp House 160 City Road, London,United Kingdom EC1V 2NX

Sales: +44 7404 607567

INDIA

2nd Floor, Sun Avenue One, Bhudarpura, Ayojan Nagar, Nr. Shyamal Cross Road, Ahmedabad, Gujarat-380006

Sales: +91 635-261-6164

For Project Inquiries

emailsales@solutionanalysts.com emailcareer@solutionanalysts.com skypebiz.solutionanalysts