Node.js Installation Guide

Node.js is a JavaScript runtime built on Chrome’s V8 engine for server-side programming.

Installation

Ubuntu/Debian (NodeSource Repository)

For the latest LTS version (22.x):

curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install -y nodejs

For the latest current version (23.x):

curl -fsSL https://deb.nodesource.com/setup_23.x | sudo -E bash -
sudo apt install -y nodejs

Fedora

sudo dnf module reset nodejs
sudo dnf module enable nodejs:22
sudo dnf install -y nodejs

Arch Linux

sudo pacman -S nodejs npm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
source ~/.bashrc
nvm install --lts
nvm install node

Verification

node --version
npm --version

Common Commands

npm -v                 # Check npm version
node -e "console.log('Hello')"  # Run inline script
npm init -y           # Initialize new project
npm install <package> # Install package locally
npm install -g <package>  # Install package globally