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.
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.
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
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 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.
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.
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.
Introduction Bash scripting is a powerful way to automate Linux tasks, but writing a script…
Introduction A self-signed SSL certificate is a certificate that is created and signed by the…
Introduction Debugging is an important part of Bash scripting. When a script does not work…
Introduction Cron jobs are used in Linux to run commands or Bash scripts automatically at…
Introduction Pipes are an important feature in Linux and Bash scripting. A pipe allows you…
Introduction The grep, awk, and sed commands are powerful text-processing tools in Linux. They are…