Installation Options
There are three ways to install Node.js:
| Method | Best For | Notes |
|---|---|---|
| Official installer | Beginners | Download from nodejs.org |
| Package manager | System-wide install | apt, brew, choco |
| Version manager (nvm) | Developers switching versions | Most flexible |
Method 1: Official Installer
Go to nodejs.org and download the LTS version (recommended for most users) or Current (latest features).
nodejs.org
โ
โโโ LTS (e.g., 22.x) โ stable, production-ready
โโโ Current (e.g., 24.x) โ latest V8, experimental APIs
After installation, verify:
node --version
# v22.x.x
npm --version
# 10.x.x
Method 2: Package Manager
macOS (Homebrew)
brew install node
Linux (Ubuntu/Debian)
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt-get install -y nodejs
Windows (winget)
winget install OpenJS.NodeJS.LTS
Method 3: Version Manager (Recommended)
nvm (Node Version Manager) lets you install and switch between multiple Node.js versions:
# Install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
# Restart terminal, then:
nvm install 22 # Install latest v22
nvm install 20 # Install latest v20
nvm use 22 # Switch to v22
nvm default 22 # Set v22 as default
Pro tip: With nvm, you can test your code against multiple Node.js versions in seconds.
What Gets Installed?
When you install Node.js, you get three things:
/usr/local/bin/
โโโ node # The JavaScript runtime
โโโ npm # Package manager
โโโ npx # Run npm packages without installing
Verify all three:
node -e "console.log('Node works')"
npm help
npx --version
Your First Node.js Project
# Create a project directory
mkdir my-first-app
cd my-first-app
# Create a file
echo 'console.log("Node.js is ready!");' > index.js
# Run it
node index.js
Updating Node.js
| Method | Command |
|---|---|
| nvm | nvm install 22 --reinstall-packages-from=20 |
| macOS Homebrew | brew upgrade node |
| Linux (nodesource) | sudo apt-get upgrade nodejs |
| Windows | Re-run the installer |
Uninstalling Node.js
# nvm
nvm uninstall 22
# macOS Homebrew
brew uninstall node
# Ubuntu/Debian
sudo apt-get remove nodejs
Key Takeaways
- Use the official installer for a quick start
- Use nvm if you switch between Node.js versions
node --versionandnpm --versionverify the installation- Node.js ships with node, npm, and npx out of the box
- Always prefer the LTS version for production