sudo apt install nodejs
sudo apt install npm 
Answer from abdelrahman aboneda on Stack Overflow
๐ŸŒ
npm
docs.npmjs.com โ€บ downloading-and-installing-node-js-and-npm
Downloading and installing Node.js and npm | npm Docs
If you are unable to use a Node version manager, you can use a Node installer to install both Node.js and npm on your system. ... If you use Linux, we recommend that you use a NodeSource installer. If you're using macOS or Windows, use one of the installers from the Node.js download page.
People also ask

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
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
Is nvm better than apt for installing npm?
Yes, in most cases. While apt is simple, it often provides outdated versions. nvm lets you install and switch between multiple Node.js/npm versions, which is essential if you manage several projects. For a detailed guide, check our article on How to Install NVM on Ubuntu.
๐ŸŒ
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
๐ŸŒ
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 - In this guide, weโ€™ll cover what npm is, why you need it, and multiple methods to install npm Ubuntu (including Ubuntu 22.04, 20.04, and older versions). ... If youโ€™re working with JavaScript or building Node.js applications on Linux, youโ€™ll realize the importance of npm (Node Package Manager).
๐ŸŒ
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 - NPM is installed alongside Node.js and is essential for managing JavaScript dependencies in a development environment. This guide covers installing NPM on Ubuntu 24.04 using multiple approaches, including package managers and manual installation.
๐ŸŒ
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 - Now we will have to curl the source directory to install the node.js and npm, for this we run the following command: curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - &&\ sudo apt-get install -y nodejs ยท Note: Here we are using setup_18.x because it's the latest version available for ubuntu, you can check if newer version is available and change the command accordingly.
๐ŸŒ
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 - Learn how to install Node.js on Ubuntu using apt, NodeSource, and NVM. Choose the best method for your needs with this beginner-friendly guide
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.

Find elsewhere
๐ŸŒ
LinuxConfig
linuxconfig.org โ€บ home โ€บ install npm on linux
Install npm on Linux: A Complete Guide
September 22, 2025 - npm is the package manager for Node.js and the JavaScript coding language. It can be installed on a Linux system and then used on the command line to download and install JavaScript packages and their requisite dependencies.
๐ŸŒ
Node.js
nodejs.org โ€บ en โ€บ download โ€บ package-manager
Node.js โ€” Download Node.jsยฎ
# download and install Node.js (you may need to restart the terminal) nvm install 22 # verifies the right Node.js version is in the environment node -v # should print "v22.12.0" # verifies the right npm version is in the environment npm -v # should print "10.9.0"
๐ŸŒ
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.
๐ŸŒ
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.
๐ŸŒ
Learn Ubuntu
learnubuntu.com โ€บ install-npm
Install NPM on Ubuntu
January 7, 2023 - This was a quick tutorial on installing the NPM package manager in Ubuntu with some basic use cases.
๐ŸŒ
GitHub
gist.github.com โ€บ thejmazz โ€บ 72456e3f29cf0bf56d4a
Install Node and npm on Linux/OS X/Windows w/o sudo ยท GitHub
TLDR; Download install-node.sh, modify the settings, make it executable (chmod u+x install-node.sh), and run it (./install-node.sh). Unless your on Windows, then you need to follow the full instructions.
๐ŸŒ
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.
๐ŸŒ
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.
๐ŸŒ
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.
๐ŸŒ
Ubuntu Shell
ubuntushell.com โ€บ install-nodejs-and-npm-on-ubuntu
How to Install Node.js and NPM on Ubuntu 25.04
June 3, 2024 - This method will install NPM v10 in conjunction with Node.js v22. How to Install Perl with Perlbrew on Ubuntu and Other Linux Distros ยท NVM (Node Version Manager) is a handy tool that allows you to seamlessly manage multiple Node.js versions concurrently without conflicts. This approach is particularly useful if you prefer using beta versions of Node.js alongside stable ones for production. 1. Run the following command to download ...
๐ŸŒ
Linode
linode.com โ€บ docs โ€บ guides โ€บ install-and-use-npm-on-linux
Install and Use the Node Package Manager (NPM) on Linux | Linode Docs
September 3, 2021 - This guide will show you how to install and use the Node Package Manager (NPM), which gives you access to a vast Node.js repository, on Linux.
๐ŸŒ
Webhi
webhi.com โ€บ home โ€บ how to install npm on debian/ubuntu or centos/rhel
How to Install NPM on Debian/Ubuntu or CentOS/RHEL - Tutorial & Documentation
February 9, 2024 - Learn how to install NPM (Node Package Manager) on Debian/Ubuntu and CentOS/RHEL Linux systems. Step-by-step guide to checking existing installations, removing old versions, and various installation methods using default repos, NodeSource, nvm, and more.
๐ŸŒ
Linuxize
linuxize.com โ€บ post โ€บ how-to-install-node-js-on-ubuntu-18.04
How to Install Node.js and npm on Ubuntu 18.04 | Linuxize
August 20, 2019 - Node.js is an open-source cross-platform JavaScript run-time environment that allows server-side execution of JavaScript code. In this tutorial, we will show you several different ways of installing Node.js and npm on Ubuntu 18.04.