sudo apt install nodejs
sudo apt install npm 
Answer from abdelrahman aboneda on Stack Overflow
๐ŸŒ
DigitalOcean
digitalocean.com โ€บ community โ€บ tutorials โ€บ how-to-install-node-js-on-ubuntu-20-04
How to Install Node.js on Ubuntu | DigitalOcean
May 2, 2025 - You can do this by installing the npm package with apt: ... This allows you to install modules and packages to use with Node.js.
๐ŸŒ
npm
docs.npmjs.com โ€บ downloading-and-installing-node-js-and-npm
Downloading and installing Node.js and npm | npm Docs
Note: to download the latest version of npm, on the command line, run the following command:npm install -g npm ... To see if you already have Node.js and npm installed and check the installed version, run the following commands:
People also ask

How to install npm on Ubuntu 20.04?
To install npm on Ubuntu 20.04, simply run: sudo apt update sudo apt install nodejs npm Then verify with: npm --version This ensures a successful npm installation Ubuntu terminal.
๐ŸŒ
monovm.com
monovm.com โ€บ ๐Ÿ“š tutorials ๐Ÿ“š โ€บ how to install npm on ubuntu: a step-by-step guide
How to Install npm on Ubuntu: A Step-by-Step Guide
Can I install npm without Node.js?
No. npm is bundled with Node.js. Installing Node.js automatically provides npm. For maximum flexibility, use nvm to install both.
๐ŸŒ
monovm.com
monovm.com โ€บ ๐Ÿ“š tutorials ๐Ÿ“š โ€บ how to install npm on ubuntu: a step-by-step guide
How to Install npm on Ubuntu: A Step-by-Step Guide
How do I update npm Ubuntu?
Run: sudo npm install -g npm@latest or, if using nvm: nvm install-latest-npm This keeps your environment secure and up to date.
๐ŸŒ
monovm.com
monovm.com โ€บ ๐Ÿ“š tutorials ๐Ÿ“š โ€บ how to install npm on ubuntu: a step-by-step guide
How to Install npm on Ubuntu: A Step-by-Step Guide
๐ŸŒ
DigitalOcean
digitalocean.com โ€บ community โ€บ tutorials โ€บ how-to-install-node-js-on-ubuntu-22-04
How to Install Node.js on Ubuntu (Step-by-Step Guide) | DigitalOcean
May 28, 2025 - $ sudo apt-get update -y $ sudo apt-get install -y ca-certificates curl gnupg $ sudo mkdir -p /etc/apt/keyrings $ curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg $ NODE_MAJOR=20 $ echo "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 $ sudo apt-get update $ sudo apt-get install -y nodejs $ node -v v20.6.1 $ npm -v 9.8.1 ... This guide provides detailed instructions for installing Node.js on an Ubuntu 22.04 server using three different methods.
๐ŸŒ
Cherry Servers
cherryservers.com โ€บ home โ€บ blog โ€บ linux โ€บ how to install npm on ubuntu 24.04 (3 methods)
How to Install NPM on Ubuntu 24.04 (3 Methods) | Cherry Servers
March 26, 2025 - To install NPM on Ubuntu 24.04, Node.js must be set up. This guide explores three installation methods: using Ubuntu's default repository, the NodeSource repository, and the Node Version Manager (NVM).
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ installation guide โ€บ how-to-install-node-js-and-npm-on-ubuntu
How to Install Node.js and npm on Ubuntu? - GeeksforGeeks
July 23, 2025 - This will install the curl into to Ubuntu system, it will show "already installed" if your system has curl already otherwise it will install it for you. ... Now we will have to curl the source directory to install the node.js and npm, for this we run the following command:
๐ŸŒ
MonoVM
monovm.com โ€บ ๐Ÿ“š tutorials ๐Ÿ“š โ€บ how to install npm on ubuntu: a step-by-step guide
How to Install npm on Ubuntu: A Step-by-Step Guide
October 4, 2025 - The APT (Advanced Package Tool) method is the simplest way to install npm on Ubuntu. It uses the default Ubuntu repositories. Always begin by updating your package lists to ensure you get the latest version available in the repository: ... You ...
Find elsewhere
๐ŸŒ
PhoenixNAP
phoenixnap.com โ€บ home โ€บ kb โ€บ devops and development โ€บ how to install node.js and npm on ubuntu
How to Install Node.js and NPM on Ubuntu
April 24, 2025 - Learn how to install Node.js and NPM on Ubuntu. This guide explains three methods: Ubuntu repository, NVM, and NodeSource repository.
๐ŸŒ
Hostman
hostman.com โ€บ tutorials โ€บ how to install node.js and npm on ubuntu 24.04
How to Install Node.js and NPM on Ubuntu | Hostman
August 28, 2025 - Initiate the Node project by running the command npm init. Provide the required details (marked in red). All of the answers in this example will be default. The file package.json will result from this.
Price ย  $
Call ย  +1 844 286 2130
Address ย  1999 Harrison St 1800 9079, 94612, Oakland
Top answer
1 of 16
269

Fresh installation

Use the NodeSource PPA. For details look at the installation instructions. First, choose the Node.js version you need and add the sources for it:

v=8   # set to 4, 5, 6, ... as needed
curl -sL https://deb.nodesource.com/setup_$v.x | sudo -E bash -

Then install the Node.js package.

sudo apt-get install -y nodejs

P.S.: curl package must be installed on server for these code lines.

Upgrading

If you have nodejs already installed and want to update, then first remove current instalation and install it again using scripts above.

sudo apt-get purge nodejs npm
2 of 16
180

Generally speaking, loading arbitrary data from a URL into a root shell session is not a good idea and I wish people would stop peddling it as a solution for everything - "Please just run this script I'm sending you, and also while we're at it - I have a bridge you'd probably be interested in purchasing".

As an alternative, here's the "Ubuntu Way" of doing the same, where you can see how the system is being updated and know what repositories and what keys are added to your system configuration:

curl https://deb.nodesource.com/gpgkey/nodesource.gpg.key | sudo apt-key add -
sudo apt-add-repository "deb https://deb.nodesource.com/node_7.x $(lsb_release -sc) main"
sudo apt-get update
sudo apt-get install nodejs

And here's the "post deprecation of apt-key way" of doing the same thing:

curl https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | sudo tee /etc/apt/keyrings/nodesource.gpg
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_7.x $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/nodejs.list
sudo apt update
sudo apt install nodejs

This is for the latest (at time of writing) Nodejs version 7. Other versions can also be gotten with a simple change to the repo URL - consult nodesource.com documentation for details.

๐ŸŒ
Node.js
nodejs.org โ€บ en โ€บ download
Node.js โ€” Download Node.jsยฎ
with npm ยท InfoWant new features sooner? Get the latest Node.js version instead and try the latest improvements! BashCopy to clipboard and their installation scripts are not maintained by the Node.js project. If you encounter any issues please visit 's website ยท
๐ŸŒ
Linuxize
linuxize.com โ€บ post โ€บ how-to-install-node-js-on-ubuntu-20-04
How to Install Node.js and npm on Ubuntu 20.04 | Linuxize
December 24, 2023 - In this tutorial, we will guide you through three different methods of installing Node.js and npm on Ubuntu 20.04.
Top answer
1 of 4
90

I recommend using Node Version Manager:

NB: Node Version Manager (nvm) allows you to install multiple node versions and choose between them depending on which software you want to support; that is, manage multiple node versions.

Installing Node Version Manager

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash

Once you have Node Version Manager installed

  1. Confirm the available remote versions by running nvm ls-remote
  2. Run in your terminal nvm install <version> for example, nvm install 18 to install version 18 of Node
  3. List installed versions with nvm list
  4. Run nvm use 18 to start using version 18 of Node
  5. Note: you can be more explicit, for example: nvm install 14.17.0
2 of 4
29

Install nodejs v20 on Debian and Ubuntu based distributions

step 1 : Download and import the Nodesource GPG key

sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg

step 2 : Create deb repository

NODE_MAJOR=20
echo "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

optional: here we are installing nodejs v20 but if you want to install v18 change NODE_MAJOR=18 in above command. Similarly if you want to install nodejs v16 then change NODE_MAJOR=16.

step 3 : Run Update and Install

sudo apt-get update
sudo apt-get install nodejs -y

congratulations you just installed nodejs

To uninstall nodejs

sudo apt-get purge nodejs &&\
rm -r /etc/apt/sources.list.d/nodesource.list &&\
rm -r /etc/apt/keyrings/nodesource.gpg
๐ŸŒ
It's FOSS
itsfoss.com โ€บ install-nodejs-ubuntu
Install Node.js and npm on Ubuntu Linux [Free Cheat Sheet]
February 7, 2024 - Node.js and npm can be easily installed using the Ubuntu repository or the NodeSource repository. Learn both ways of installing Node.js on Ubuntu Linux.
๐ŸŒ
Linuxize
linuxize.com โ€บ post โ€บ how-to-install-node-js-on-ubuntu-22-04
How to Install Node.js and npm on Ubuntu 22.04 | Linuxize
December 24, 2023 - In this tutorial, we will explore three different ways of installing Node.js and npm on Ubuntu 22.04.
๐ŸŒ
BlueVPS
bluevps.com โ€บ blog โ€บ how to install node.js on ubuntu 22.04: step-by-step guide
How to Install Node.js on Ubuntu 22.04: Step-by-Step Guide - Blog - BlueVPS
Once you update all repositories on your system, install Node.js on the Ubuntu 22.04 system using the following command: After executing the command above, you need to confirm the user confirmation prompts, and then it will install Node.js and npm (Node Package Manager) on your system.
๐ŸŒ
Vultr
docs.vultr.com โ€บ how-to-install-node-js-and-npm-on-ubuntu-24-04
How to Install Node.js and NPM on Ubuntu 24.04 | Vultr Docs
July 25, 2024 - Learn to install Node.js and NPM on Ubuntu 24.04 using NodeSource PPA and manage versions with NVM efficiently.