How to Install Node.js on Ubuntu 26.04

Node.js is a powerful JavaScript runtime built on Chrome’s V8 engine, and knowing how to complete a nodejs install ubuntu 26.04 is an essential skill for developers and system administrators alike. This guide walks you through every available installation method so you can choose the one that best fits your workflow and version requirements.

In this tutorial you will learn:

  • How to install Node.js from Ubuntu 26.04’s default repositories
  • How to install a specific Node.js LTS or current version via the NodeSource repository
  • How to manage multiple Node.js versions using NVM
  • How to verify the installation and check the installed version
  • How to use npm to manage Node.js packages
  • How to safely uninstall Node.js from Ubuntu 26.04
Install Node.js on Ubuntu 26.04 using apt, NodeSource, or NVM

Software Requirements

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Ubuntu 26.04 Resolute Raccoon
Software Node.js 20.x LTS / 22.x LTS / latest current release, npm (bundled), nvm (optional)
Other Privileged access to your Linux system as root or via the sudo command.
Conventions $ sudo – requires given linux commands to be executed with root privileges by use of the sudo command
$ – requires given linux commands to be executed as a regular non-privileged user
TL;DR
To complete a nodejs install on Ubuntu 26.04 quickly using NVM (recommended for flexibility), run the following commands:

Quick Steps to Install Node.js on Ubuntu 26.04
Step Command/Action
1. Install NVM curl -o- | bash
2. Reload shell source ~/.bashrc
3. Install Node.js LTS nvm install --lts
4. Verify installation node --version && npm --version

Method 1: Install Node.js from Ubuntu Repositories

The simplest way to perform a nodejs install on Ubuntu 26.04 is to use the packages available directly in Ubuntu’s default repositories. This method requires no additional repository configuration and therefore integrates cleanly with the system package manager. The trade-off is that the version included in the repos may lag behind the latest upstream release.

First, update the package index to ensure you have the most current information:

  1. Update package index: Refresh the apt package cache before installing anything.
    $ sudo apt update

    This ensures apt is aware of the latest available packages in all configured repositories.

  2. Install Node.js and npm: Install both Node.js and its package manager in a single command.
    $ sudo apt install nodejs npm

    Ubuntu 26.04 bundles npm separately from nodejsso both package names are required here.

Terminal output showing apt install nodejs npm on Ubuntu 26.04 with 406 packages and 279 MB download confirmation promptTerminal output showing apt install nodejs npm on Ubuntu 26.04 with 406 packages and 279 MB download confirmation prompt
apt install nodejs npm on Ubuntu 26.04 – package summary showing 406 packages to be installed

IMPORTANT

The Node.js version in Ubuntu’s default repositories may not be the latest LTS. If your project requires a specific Node.js version, use Method 2 or Method 3 instead.

Method 2: Install Node.js via NodeSource Repository

The NodeSource repository provides up-to-date Node.js packages for Debian-based distributions, including Ubuntu 26.04. This method consequently gives you access to specific major versions such as Node.js 20 LTS or Node.js 22 LTS without having to manage multiple runtime versions yourself.

NodeSource provides a setup script that configures the repository and installs the required GPG key automatically. Choose the major version you need before running the script.

  1. Install prerequisites: Ensure curl is available to download the setup script.
    $ sudo apt install -y curl
  2. Add the NodeSource repository: Run the setup script for your desired Node.js major version. The example below sets up Node.js 22.x (current LTS at time of writing).
    $ curl -fsSL  | sudo bash -

    The script adds the NodeSource apt repository and imports its GPG signing key. Replace 22.x with 20.x if you require the Node.js 20 LTS branch.

  3. Install Node.js: After the repository is configured, install Node.js with apt.
    $ sudo apt install -y nodejs

    This package from NodeSource includes npm bundled together, so no separate npm installation is necessary.

Terminal showing sudo apt install -y nodejs from NodeSource repository on Ubuntu 26.04, installing Node.js 22.22.0 with node --version outputTerminal showing sudo apt install -y nodejs from NodeSource repository on Ubuntu 26.04, installing Node.js 22.22.0 with node --version output
apt install nodejs from NodeSource installs Node.js 22.22.0 on Ubuntu 26.04

IMPORTANT

NodeSource packages bundle npm, so you do not need to install npm separately when using this method. Running apt install nodejs npm would install a conflicting npm version from the Ubuntu repos.

Method 3: Install Node.js via NVM

Node Version Manager (NVM) is the most flexible approach to performing a nodejs install on Ubuntu 26.04, especially if you work on multiple projects that require different Node.js versions. NVM installs Node.js in your home directory, meaning you do not need root privileges for installation or version switching. Moreover, switching between Node.js versions is a single command operation.

  1. Download and run the NVM install script: The official NVM installer script handles everything automatically.
    $ curl -o-  | bash

    The script clones the NVM repository to ~/.nvm and adds the required initialization lines to your shell profile (~/.bashrc, ~/.zshrcor ~/.profile depending on your shell).

  2. Reload your shell configuration: Apply the changes to your current session without logging out.
    $ source ~/.bashrc

    After this step, the nvm command becomes available in your terminal.

  3. Verify NVM is installed: Confirm that NVM loaded correctly.
    $ nvm --version

    You should see the NVM version number printed to the terminal.

  4. List available Node.js versions (optional): Browse the available LTS and current releases.
    $ nvm ls-remote --lts
  5. Install Node.js LTS: Install the latest Long-Term Support release.
    $ nvm install --lts

    Alternatively, install a specific version by number, for example nvm install 22.3.0.

  6. Set a default Node.js version: Make a version the default across new terminal sessions.
    $ nvm alias default node

    This ensures the most recently installed version is used in all future sessions.

Terminal showing nvm install --lts on Ubuntu 26.04 downloading and installing Node.js v24.14.0 with npm v11.9.0Terminal showing nvm install --lts on Ubuntu 26.04 downloading and installing Node.js v24.14.0 with npm v11.9.0
nvm install –lts installs Node.js v24.14.0 (npm v11.9.0) as the default LTS on Ubuntu 26.04

Switching Between Node.js Versions with NVM

One of the key advantages of NVM is the ability to switch between installed Node.js versions instantly. This is particularly useful when maintaining legacy applications alongside modern projects.

  1. Install an additional version: Install Node.js 20 LTS alongside the current version.
    $ nvm install 20
  2. Switch to a specific version: Use that version for the current shell session.
    $ nvm use 20
  3. List installed versions: View all Node.js versions currently managed by NVM.
    $ nvm ls
Terminal showing nvm install 20, nvm use 20, and nvm ls output on Ubuntu 26.04 with v20.20.0 and v24.14.0 installedTerminal showing nvm install 20, nvm use 20, and nvm ls output on Ubuntu 26.04 with v20.20.0 and v24.14.0 installed
nvm ls showing v20.20.0 (active) and v24.14.0 installed alongside each other on Ubuntu 26.04

Verify the Node.js Installation on Ubuntu 26.04

Regardless of the installation method you chose, verifying the nodejs install on Ubuntu 26.04 ensures everything is working correctly before you begin development.

  1. Check the Node.js version:
    $ node --version

    Expected output (version will vary):

    v24.14.0
  2. Check the npm version:
    $ npm --version

    Expected output:

    11.9.0
  3. Run a quick test script: Confirm the runtime executes JavaScript correctly.
    $ node -e "console.log('Node.js is running on Ubuntu 26.04')"

    Expected output:

    Node.js is running on Ubuntu 26.04
Terminal showing node --version returning v24.14.0, npm --version returning 11.9.0, and node -e test script output on Ubuntu 26.04Terminal showing node --version returning v24.14.0, npm --version returning 11.9.0, and node -e test script output on Ubuntu 26.04
Node.js v24.14.0 and npm 11.9.0 verified and running on Ubuntu 26.04

COMPLETED

If all three commands above returned expected output, your Node.js installation on Ubuntu 26.04 is complete and working correctly.

Managing Packages with npm

After completing the nodejs install on Ubuntu 26.04, npm is immediately available for package management. npm is the default package manager for Node.js and provides access to the largest ecosystem of open-source libraries in the world.

Here are the most common npm operations you will use regularly:

  1. Initialize a new Node.js project: Create a package.json file in the current directory.
    $ npm init -y

    The -y flag accepts all default values, which speeds up project initialization.

  2. Install a package locally: Add a dependency to your current project.
    $ npm install express

    The package is installed in the node_modules directory and recorded in package.json.

  3. Install a package globally: Install a CLI tool available system-wide.
    $ npm install -g nodemon

    Global packages are useful for development tools you want accessible from any directory.

  4. Update npm itself: Keep npm up to date with the latest release.
    $ npm install -g npm@latest

IMPORTANT

When using NVM, global npm packages are installed per Node.js version. If you switch versions with nvm useyou may need to reinstall global packages for that version.

Uninstalling Node.js from Ubuntu 26.04

The uninstall procedure depends on which method you used to install Node.js.

  1. Uninstall (apt method): Remove Node.js and npm installed from Ubuntu repositories or NodeSource.
    $ sudo apt remove nodejs npm
    $ sudo apt autoremove

    The autoremove command additionally cleans up any orphaned dependency packages.

  2. Uninstall a specific NVM version: Remove a single version while keeping others.
    $ nvm uninstall 20
  3. Remove NVM entirely: Uninstall NVM and all Node.js versions it manages.
    $ rm -rf ~/.nvm

    After removing the directory, also delete the NVM initialization lines from your ~/.bashrc or shell profile file.

Conclusion

This guide covered three distinct methods to nodejs install on Ubuntu 26.04: using the default Ubuntu repositories for simplicity, using the NodeSource repository for a specific major version, and using NVM for maximum flexibility across multiple versions. For most development workflows, NVM is the recommended approach because it allows version switching without root access and keeps your system Node.js installation untouched. For production servers where a single pinned version is required, the NodeSource method provides well-maintained, up-to-date packages through the standard apt workflow. Additionally, always verify your installation after completing any of these methods to confirm everything is working as expected before starting your project.

Frequently Asked Questions

  1. Which Node.js installation method is best for Ubuntu 26.04? It depends on your use case. NVM is the best choice for developers who need to switch between Node.js versions across different projects. The NodeSource repository is ideal for servers that require a specific, well-maintained LTS version managed through apt. The Ubuntu default repositories are suitable if you only need Node.js for a basic use case and do not require the latest version.
  2. Can I install multiple Node.js versions on Ubuntu 26.04 at the same time? Yes, but only NVM supports this natively. With NVM, you can install as many Node.js versions as you need and switch between them using nvm use <version>. The apt-based methods (Ubuntu repos and NodeSource) only allow one active version at a time, since they install to system paths.
  3. How do I check which Node.js version is currently active on Ubuntu 26.04? Run node --version in your terminal. If you are using NVM, you can additionally run nvm current to see which version NVM has activated, or nvm ls to see all installed versions with the active one highlighted.
  4. Why does “node” not work after running “apt install nodejs” on Ubuntu 26.04? On older Ubuntu releases, the nodejs binary was sometimes installed as nodejs rather than node due to a naming conflict with a legacy package. On Ubuntu 26.04 this conflict is resolved, so node should work directly after installation. If it does not, verify the installation with which nodejs and create a symlink if needed: sudo ln -s /usr/bin/nodejs /usr/local/bin/node.
  5. Does the nodejs install on Ubuntu 26.04 include npm automatically? It depends on the method. When using NodeSource or NVM, npm is bundled with Node.js and installed automatically. When using the Ubuntu default repositories, you need to install npm separately with apt install npmsince the Ubuntu repos package them independently.

Berita Terkini

Berita Terbaru

Daftar Terbaru

News

Jasa Impor China

Berita Terbaru

Flash News

RuangJP

Pemilu

Berita Terkini

Prediksi Bola

Technology

Otomotif

Berita Terbaru

Teknologi

Berita terkini

Berita Pemilu

Berita Teknologi

Hiburan

master Slote

Berita Terkini

Pendidikan

Resep

Jasa Backlink

Slot gacor terpercaya

Anime Batch

Leave a Reply

Your email address will not be published. Required fields are marked *