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

git fetch vs git pull: How They Work and When to Use Each

Both git fetch and git pull talk to a remote repository, but they do very different things to your…

2 days ago

git cherry-pick Command: Apply Commits from Another Branch

Sometimes the change you need already exists, just on the wrong branch. A hotfix lands…

2 days ago

Best Email APIs for Secure Business Email: Why Developers Are Moving Beyond SMTP

Email is still one of the most important communication channels inside modern applications. Password resets,…

3 days ago

Nginx Commands in Linux: Start, Stop, Reload, Test, and Log

Nginx is a high-performance web server and reverse proxy trusted by some of the largest…

6 days ago

ufw Command in Linux: Manage Firewall Rules with Examples

ufw (Uncomplicated Firewall) sits on top of iptables (or nftables on newer systems) and replaces…

6 days ago

who Command in Linux: Show All Logged-In Users and Sessions

When you share a server with a team or investigate unexpected activity, the first question…

6 days ago