Open Terminal
Update package lists: `sudo apt update`
Install prerequisites: `sudo apt install -y curl ca-certificates`
Add NodeSource repository for the desired Node.js version: `curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -`
Install Node.js: `sudo apt install -y nodejs`
Verify installation: `node -v`
Verify npm installation: `npm -v`
Optional: install build tools: `sudo apt install -y build-essential`
Optional: install a version manager instead: `curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash`
Optional: load nvm and install Node: `nvm install –lts`
