I really recommend you install node and npm using nvm. This is the fastest, cleanest and easiest way to do it.

That way, you install NVM simply doing:

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

To test that nvm was properly installed, close and re-open Terminal and enter nvm. If you get a nvm: command not found message, your OS may not have the necessary .bash_profile file. In Terminal, enter touch ~/.bash_profile and run the above install script again.

And you are now able to install node typing:

nvm install <version>

For example

nvm install 4.2.1

if you just want to install the latest node version, you can just type

nvm install node

In order to access node and npm as sudo (in order to have <1024 ports) you should run

n=$(which node)
n=${n%/bin/node}
chmod -R 755 $n/bin/* 
sudo cp -r $n/{bin,lib,share} /usr/local 
Answer from Luis González 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.
🌐
npm
npmjs.com › package › node-linux-x64
node-linux-x64 - npm
Binaries, installers, and source tarballs are available at https://nodejs.org/en/download/.
      » npm install node-linux-x64
    
Published   Sep 11, 2025
Version   24.8.0
🌐
Kinsta®
kinsta.com › home › resource center › blog › node.js › how to install node.js and npm on windows, macos, and linux
How to install Node.js and npm on Windows, macOS, and Linux
May 31, 2024 - There’s only a 64-bit version, so you don’t have to worry about which to download. Downloading the Node.js macOS installer. Check your Download folder for the installer file and click on it to start the installation process. The Node.js installer carries the Node.js core file, and, consequently, the installation process installs both Node.js and npm from the installer file.
🌐
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.
🌐
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.
🌐
Ramotion
ramotion.com › blog › how-to-install-npm
A Step-by-Step Guide to Install NPM for Beginners | Ramotion Agency
July 10, 2025 - Complete fuide how to install NPM is here. Learn to install npm, the Node Package Manager, on Windows, macOS, and Linux.
🌐
Node.js
nodejs.org › en › download
Node.js — Download Node.js®
Node.js® is a free, open-source, cross-platform JavaScript runtime environment that lets developers create servers, web apps, command line tools and scripts.
Find elsewhere
🌐
LinuxConfig
linuxconfig.org › home › install npm on linux
Install npm on Linux: A Complete Guide
September 22, 2025 - Use the appropriate command on your major linux distros to install npm. On some distributions, npm is installed along with the nodejs package. On others, the two packages are installed separately. The following commands will install both npm and Node.js.
🌐
Pkgs.org
pkgs.org › download › npm
Npm Download for Linux (apk deb pkg rpm txz xz zst)
Download npm linux packages for AlmaLinux, Alpine, ALT Linux, Arch Linux, CentOS, Debian, Fedora, FreeBSD, Mageia, NetBSD, OpenMandriva, openSUSE, PCLinuxOS, Rocky Linux, Ubuntu · Filter: Distros: all Arches: arm intel Types: official thirdparty ... npm latest versions: 18.5.0, 17.7.1, 17.5.0, 17.3.1, 16.15.1, 16.15.0, 16.14.1, 14.19.1, 14.19.0, 14.16.0, 12.21.0, 10.24.0, 8.17.0, 8.13.2, 8.13.0 · npm architectures: aarch64, all, amd64, any, i586, noarch, ppc64le, s390x, x86_64
🌐
GitHub
github.com › nvm-sh › nvm
GitHub - nvm-sh/nvm: Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions
Downloading https://nodejs.org/dist/v5.9.1/node-v5.9.1-linux-x64.tar.xz... #################################################################################### 100.0% Computing checksum with sha256sum Checksums matched! Now using node v5.9.1 (npm v3.7.3)
Starred by 90.3K users
Forked by 9.7K users
Languages   Shell 98.0% | Makefile 1.2%
🌐
Latenode
latenode.com › home › apps › how to install node.js and npm on windows, macos, and linux
How to Install Node.js and NPM on Windows, macOS, and Linux
Once the installation is complete, you can verify the installed versions by running the following commands: Copy node -v ... Under the "Linux Binaries" section, download the appropriate binary for your Ubuntu version (32-bit or 64-bit).
🌐
npm
npmjs.com › package › node-win-x64
node-win-x64 - npm
node. Latest version: 20.19.6, last published: 7 days ago. Start using node-win-x64 in your project by running `npm i node-win-x64`. There are 1 other projects in the npm registry using node-win-x64.
      » npm install node-win-x64
    
Published   Nov 26, 2025
Version   20.19.6
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.

🌐
Carmatec
carmatec.com › home › how to install node.js and npm on windows, macos, & linux
How to Install Node.js and npm on Windows, macOS, & Linux
August 23, 2024 - Node.js is a powerful JavaScript runtime environment that enables you to run JavaScript code on the server side. npm (Node Package Manager) is the default package manager for Node.js and is essential for managing JavaScript packages and dependencies. In this guide, we’ll walk you through the steps to install Node.js and npm on Windows, macOS, and Linux. ... Visit the Node.js official website. Download the Windows Installer (.msi) for the LTS (Long Term Support) version.
🌐
npm
npmjs.com › package › esbuild-linux-64
esbuild-linux-64 - npm
This is the Linux 64-bit binary for esbuild, a JavaScript bundler and minifier.
      » npm install esbuild-linux-64
    
Published   Dec 05, 2022
Version   0.15.18
🌐
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.
🌐
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).
🌐
Node.js
nodejs.org › en › blog › release › v24.11.0
Node.js — Node.js v24.11.0 (LTS)
Windows 64-bit Installer: https://nodejs.org/dist/v24.11.0/node-v24.11.0-x64.msi Windows ARM 64-bit Installer: https://nodejs.org/dist/v24.11.0/node-v24.11.0-arm64.msi Windows 64-bit Binary: https://nodejs.org/dist/v24.11.0/win-x64/node.exe Windows ARM 64-bit Binary: https://nodejs.org/dist/v24.11.0/win-arm64/node.exe macOS 64-bit Installer: https://nodejs.org/dist/v24.11.0/node-v24.11.0.pkg macOS Apple Silicon 64-bit Binary: https://nodejs.org/dist/v24.11.0/node-v24.11.0-darwin-arm64.tar.gz macOS Intel 64-bit Binary: https://nodejs.org/dist/v24.11.0/node-v24.11.0-darwin-x64.tar.gz Linux 64-bi
🌐
GeeksforGeeks
geeksforgeeks.org › node.js › how-to-download-and-install-node-js-and-npm
How to Download and Install Node.js and NPM - GeeksforGeeks
July 23, 2025 - Click on the version you wish to download. The website will automatically detect your operating system and recommend the appropriate version (Windows, macOS, or Linux).