How to install Node.js on Ubuntu
Method 1: Using the Ubuntu repository (easiest)
sudo apt update
sudo apt install nodejs npm -ynode --version
npm --versionMethod 2: Using NodeSource (recommended for most people)
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -sudo apt install nodejs -yMethod 3: Using NVM (best for developers who switch versions)
Verifying npm works
Installing Yarn (optional)
Setting up a simple project
Managing Node.js processes
Common issues
Summary
Method
Best for
Last updated