Unravel the Magic: How to Install Node js On Ubuntu 22.04

Introduction:

In this post we will see how to install Node js on Ubuntu 22.04, enabling you to embark on a journey of innovation and creativity in your web projects.

Node.js has become an integral part of modern web development, empowering developers to build scalable and efficient applications. If you’re using Ubuntu 22.04 and eager to unlock the magic of Node.js, you’re in the right place.

Understanding the Power of Node.js:

Before diving into the installation process, let’s explore why Node.js is a game-changer for web development. From its event-driven architecture to its vast ecosystem of modules and libraries, discover how Node.js enables developers to build fast, scalable, and real-time applications. Unravel the magic that lies behind Node.js’s immense popularity and its impact on the web development landscape.

Preparing Your Ubuntu 22.04 Environment:

To ensure a smooth installation of Node.js, we will guide you through the necessary preparations. From updating your Ubuntu system to installing essential dependencies, we’ll help you set the stage for a successful Node.js installation.

Choosing the Right Node.js Version:

Node.js offers different versions, each with its own set of features and advantages. We’ll discuss the different release lines and help you choose the appropriate version for your Ubuntu 22.04 setup. Whether you need the latest features or require long-term support, we’ll guide you in making an informed decision.

Install Node js with Package Manager:

Ubuntu 22.04 provides a package manager that simplifies the installation process. We’ll show you how to use the package manager to install Node.js effortlessly. Follow our instructions, and soon you’ll have Node.js up and running on your Ubuntu 22.04 machine.

Verifying Your Node.js Installation

Once the installation is complete, it’s essential to verify that Node.js is functioning correctly. We’ll walk you through the verification process, ensuring that Node.js is successfully installed on your Ubuntu 22.04 system. This step is crucial to confirm that everything is set for you to start creating amazing web applications.

Step 1 – Download and import the Nodesource GPG key

sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg

Step 2 – Create deb repository

NODE_MAJOR=18
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list

The above will install node 18, if you want to use some other version then use the below version.

You can view the official docs – HERE

NODE_MAJOR=16
NODE_MAJOR=18
NODE_MAJOR=20
NODE_MAJOR=21

Step 3 – Run Update and Install

sudo apt-get update
sudo apt-get install nodejs -y

After installing node js, check the node version by the below command

node -v 

#OUTPUT
v18.18.2

Uninstall nodejs Ubuntu & Debian packages

sudo apt-get purge nodejs &&\
rm -r /etc/apt/sources.list.d/nodesource.list &&\
rm -r /etc/apt/keyrings/nodesource.gpg

You can try node js with Ubuntu server also – https://developernoob.com/ubuntu-server-setup-tutorial-for-beginners/

Leave a Comment