4 Ways to Install Node.js on Ubuntu

4 Ways to Install Node.js on Ubuntu

Bitnesia Development Mar 25, 2026 110 ID

Node.js is a JavaScript runtime platform based on Google Chrome’s V8 engine that allows us to run JavaScript outside the browser. With Node.js, developers can build server-side applications, APIs, and real-time applications such as chat and streaming services. Thanks to its vast ecosystem and npm (Node Package Manager) support, Node.js has become a popular choice among web and backend developers.

If you are using Ubuntu, there are several ways to install Node.js depending on your needs: from the default Ubuntu repository, the NodeSource repository, Node.js version managers (NVM), to Volta. Each method has its own advantages and disadvantages.

1. Install Node.js from the Default Ubuntu Repository

The simplest method is to use Ubuntu’s built-in repository.
For example, on Ubuntu 24.04, Node.js version 18.19 is available by default.

sudo apt install nodejs -y
sudo apt install npm -y

Advantages:

  • Easy and quick, no additional configuration required.
  • Suitable for general use or production servers that require stability.

Disadvantages:

  • The Node.js version is usually older compared to the latest releases.

2. Install Node.js from the NodeSource Repository

If you need a newer version, use the NodeSource repository. For example, to install Node.js v22.x:

curl -fsSL https://deb.nodesource.com/setup_22.x   | sudo bash -
sudo apt install nodejs -y

Advantages:

  • Provides a more up-to-date version of Node.js.
  • Suitable for applications that require the latest Node.js features.

Disadvantages:

  • The Node.js version is installed globally, and only one version can be active on the system.

3. Install Node.js with NVM (Node Version Manager)

NVM allows you to install multiple versions of Node.js simultaneously and switch between them easily.

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh   | bash
source ~/.bashrc
nvm install 22
nvm use 22

Advantages:

  • Supports installing multiple Node.js versions.
  • Easy switching between versions (nvm use 18, nvm use 22, etc.).
  • Ideal for developers working on multiple projects with different Node.js versions.

Disadvantages:

  • Not suitable for production servers due to user-based configuration.

4. Install Node.js with Volta

Volta is a JavaScript toolchain manager. Its main advantage is the ability to set Node.js versions per project, ensuring each project runs consistently with its specified version.

curl https://get.volta.sh   | bash
source ~/.bashrc
volta install node@22

How to select a Node.js version with Volta:

cd my-app
npm init -y
volta pin node@22

Advantages:

  • Node.js version can be specified per project.
  • Well-suited for modern development workflows.
  • Can also manage npm, yarn, and pnpm.

Disadvantages:

  • More commonly used among developers than system administrators.

Differences Between Methods

MethodBest ForNode.js VersionFlexibility
Ubuntu RepoProduction servers, beginnersOlder/stableLow
NodeSourceNeed latest versionUp-to-dateLow
NVMDevelopers with multiple projectsMultiple versionsHigh
VoltaModern developers, per projectFlexibleHigh

There are many ways to install Node.js on Ubuntu, and the right choice depends on your needs. If you want something quick and stable, use the default Ubuntu repository. If you need the latest version, use NodeSource. If you are a developer working on multiple projects, NVM is the right choice. Meanwhile, if you prefer a modern workflow with per-project version management, Volta is the best solution. By understanding the differences between these methods, you can choose the most suitable way to install Node.js for your needs, whether for production servers or application development.

I love keeping these tutorials free for everyone. If you've saved time or learned something new today, consider making a small donation to keep this site ad-free.

Support Free Content

Related Posts