How to Install Node.js and npm on Ubuntu 26.04

Updated on 24 April, 2026
Install Node.js JavaScript runtime and npm package manager on an Ubuntu 26.04 for server-side application development and dependency tools.
How to Install Node.js and npm on Ubuntu 26.04 header image

Node.js is an open-source, cross-platform JavaScript runtime built on the V8 engine that enables server-side application development. npm (Node Package Manager) ships with Node.js and provides access to a registry of over two million packages for managing project dependencies, scripts, and build tools.

This article explains how to install Node.js and npm on an Ubuntu 26.04 server using the NodeSource repository, test the installation with a sample Express application, and manage multiple Node.js versions using NVM (Node Version Manager).

Prerequisites

Before you begin, you need to:

Install Node.js

The default Ubuntu 26.04 repositories include a Node.js package, but it may not be the latest version. Two installation methods are available: the NodeSource PPA for system-wide installation, or NVM for per-user version management.

Install Using NodeSource

The NodeSource PPA provides up-to-date Node.js releases for specific major versions. This method installs Node.js and npm system-wide.

  1. Update the APT package index.

    console
    $ sudo apt update
    
  2. Download the NodeSource setup script for your desired major version. For example, Node.js 24.x.

    console
    $ curl -fsSL https://deb.nodesource.com/setup_24.x -o nodesource_setup.sh
    

    Refer to the NodeSource distributions page to view all available Node.js versions.

  3. Run the setup script to add the repository.

    console
    $ sudo bash nodesource_setup.sh
    
  4. Install Node.js and npm.

    console
    $ sudo apt install nodejs -y
    
  5. Confirm the installed Node.js version.

    console
    $ node -v
    

    Your output should be similar to the one below:

    v24.13.0
  6. Confirm the installed npm version.

    console
    $ npm -v
    

    Your output should be similar to the one below:

    11.6.2

Test the Installation

The following steps create a sample Express web application to verify that Node.js and npm are functioning correctly.

  1. Create a new project directory and navigate into it.

    console
    $ mkdir ~/example-app && cd ~/example-app
    
  2. Initialize a new Node.js project.

    console
    $ npm init -y
    
  3. Install the Express framework.

    console
    $ npm install express
    
  4. Create the application file.

    console
    $ nano index.js
    
  5. Add the following code to the file.

    js
    const express = require('express')
    const app = express()
    const port = 3000
    
    app.get('/', (req, res) => {
        res.send('Hello World from Node.js')
    })
    
    app.listen(port, () => {
        console.log(`Application listening on port ${port}`)
    })
    

    Save and close the file.

    This Express application starts an HTTP server on port 3000 that returns a plain text response.

  6. Allow port 3000 through the firewall.

    console
    $ sudo ufw allow 3000/tcp
    
  7. Start the application.

    console
    $ node index.js
    

    The terminal displays Application listening on port 3000.

  8. Open a new terminal session and test the application using curl.

    console
    $ curl http://localhost:3000
    

    A successful response returns:

    Hello World from Node.js

    Press Ctrl + C in the original terminal to stop the application.

Conclusion

You have installed Node.js and npm on an Ubuntu 26.04 server using the NodeSource repository, tested the setup with an Express application, and configured NVM for managing multiple Node.js versions. NVM enables switching between versions without affecting system-wide packages. For more information, refer to the official Node.js documentation.

Comments