How to install the latest Node.js on Ubuntu

Ubuntu's default Node.js package follows the operating-system release, while many JavaScript projects ask for a newer upstream runtime. NodeSource publishes APT packages for active Node.js release lines, including the Current line used for the newest major version before it becomes LTS.

The setup_current.x script adds the NodeSource repository for the current major line and leaves package installation to APT. The package is named nodejs, the runtime command is node, and npm is bundled with the NodeSource package.

Use this method when a development host, test server, or build machine needs the Current release instead of Ubuntu's repository version. For production systems, prefer an active LTS line unless the application has already been tested on Current; the exact patch version comes from the NodeSource repository when APT installs the package.

Steps to install the latest Node.js on Ubuntu with NodeSource:

  1. Open a terminal with sudo privileges.
  2. Refresh the APT package index.
    $ sudo apt update
  3. Install curl for downloading the NodeSource setup script.
    $ sudo apt install --assume-yes curl
  4. Download the NodeSource Current setup script.
    $ curl --fail --silent --show-error --location https://deb.nodesource.com/setup_current.x --output nodesource_setup.sh
  5. Add the NodeSource repository.
    $ sudo bash nodesource_setup.sh
    Installing pre-requisites
    ##### snipped #####
    Repository configured successfully.
    To install Node.js, run: apt install nodejs -y

    The Current script selected the node_26.x repository during validation. NodeSource updates this target as the upstream Current line changes.

  6. Install the NodeSource Node.js package.
    $ sudo apt install --assume-yes nodejs
    Reading package lists...
    Building dependency tree...
    Reading state information...
    Solving dependencies...
    Installing:
      nodejs
    ##### snipped #####
    Get:2 https://deb.nodesource.com/node_26.x nodistro/main arm64 nodejs arm64 26.3.1-1nodesource1 [40.1 MB]
    ##### snipped #####
    Setting up nodejs (26.3.1-1nodesource1) ...

    The architecture and patch version may differ on another Ubuntu host. The important signal is that APT installs nodejs from deb.nodesource.com.

  7. Confirm the installed Node.js runtime.
    $ node --version
    v26.3.1
  8. Confirm the bundled npm command.
    $ npm --version
    11.16.0
  9. Run a short Node.js smoke test.
    $ node --eval "console.log('Node.js ' + process.version + ' is running')"
    Node.js v26.3.1 is running
  10. Remove the downloaded setup script.
    $ rm nodesource_setup.sh