Node.js can be installed directly from nodejs.org, but using nvm (Node Version Manager) is recommended because it lets you switch between Node versions easily.
After installation, the node and npm commands become available in your terminal.
Node.js can be installed directly from nodejs.org, but using nvm (Node Version Manager) is recommended because it lets you switch between Node versions easily.
After installation, the node and npm commands become available in your terminal.
# Install nvm on Linux/macOS:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
# Install and use a specific Node version:
nvm install 20
nvm use 20
nvm alias default 20
# Verify installation:
node --version # e.g. v20.11.0
npm --version # e.g. 10.2.4
# On Windows — use nvm-windows:
# https://github.com/coreybutler/nvm-windows
# nvm install 20.11.0
# nvm use 20.11.0
# Open the Node REPL (interactive shell):
node
# > 2 + 2
# 4
# > .exit