How To

Install Node.js Ubuntu for Modern JavaScript Development

If you want to build scalable web applications or run JavaScript outside the browser, learning how to Install Node.js Ubuntu systems correctly is essential. Node.js powers modern backend development, APIs, automation tools, and real-time applications across Linux environments.

Ubuntu 22.04 provides multiple ways to install Node.js and npm. Depending on your requirements, you can use the official Ubuntu repositories, NodeSource packages, or NVM for flexible version management.

Why Install Node.js Ubuntu Systems?

Node.js is an open-source JavaScript runtime built on Google Chrome’s V8 engine. It allows developers to execute JavaScript code directly on servers, making it ideal for backend applications and cloud-native development.

npm, which comes bundled with Node.js, is the default package manager used to install libraries and dependencies for JavaScript projects.

Before installation, check whether Node.js already exists on your machine:

node -v

If Ubuntu returns a “command not found” message, proceed with one of the installation methods below.

Install Node.js Ubuntu Using NodeSource

NodeSource offers updated Node.js packages that are more suitable for production servers than Ubuntu’s default repository versions.

Start by installing the required dependencies:

sudo apt updatesudo apt install ca-certificates curl gnupg

Next, import the NodeSource repository key:

sudo mkdir -p /etc/apt/keyringscurl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg

Enable the Node.js 22 repository:

NODE_MAJOR=22echo "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

Install Node.js and npm:

sudo apt updatesudo apt install nodejs

Verify the installation:

node --versionnpm --version

Install Node.js Ubuntu with NVM

Many developers prefer NVM because it allows multiple Node.js versions on the same machine. This method is perfect for testing applications across different environments.

Download and install NVM:

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash

After reopening the terminal, verify NVM:

nvm -v

Install the latest Node.js version:

nvm install node

To install the latest long-term support release:

nvm install --lts

Switch between versions easily:

nvm use 24

NVM gives developers complete flexibility without affecting system-wide packages.

Ubuntu Repository Installation Option

Ubuntu also provides Node.js packages through its default repositories:

sudo apt updatesudo apt install nodejs npm

However, Ubuntu 22.04 ships with an outdated Node.js release. For production systems, NodeSource or NVM remains the better choice.

Managing and Removing Node.js

To uninstall Node.js installed through Apt:

sudo apt remove nodejs

If you installed Node.js with NVM:

nvm uninstall 22

This makes it easy to clean up unused versions and maintain a stable development environment.

Conclusion

Understanding how to Install Node.js Ubuntu systems properly helps developers create faster and more reliable JavaScript applications. Whether you use NodeSource for production deployments, NVM for version management, or Ubuntu repositories for basic setups, Ubuntu 22.04 offers flexible installation options for every workflow.

With Node.js and npm installed, you are ready to start building modern web applications, APIs, and scalable backend services.

Cyber Defence

Recent Posts

groupdel Command in Linux: Remove a Group and Audit Files

The groupdel command in Linux removes a group from the system. It deletes the group's entry from /etc/group and /etc/gshadow,…

11 hours ago

wc Command in Linux: Count Lines, Words, Characters, and Bytes

The wc command in Linux counts lines, words, characters, and bytes in files or standard input. It…

11 hours ago

top Command in Linux: Monitor Processes and Resource Usage

The top command in Linux provides a real-time view of running processes and system resource usage. From…

12 hours ago

usermod Command in Linux: Modify User Accounts and Groups

The usermod command in Linux modifies existing user account attributes. You can use it to manage group…

12 hours ago

sort Command in Linux: Sort Text, Numbers, Columns, and More

The sort command in Linux reads lines from files or standard input and writes them to standard…

2 days ago

wall Command in Linux: Broadcast Messages to Logged-In Users

The wall command in Linux sends a message to the terminals of all currently logged-in users. The…

2 days ago