Master Code
On The Go

Learn. Practice. Build.

Home › How-To › Update Node.js

How-To Guide

How to Update Node.js

Updating Node.js is essential for security patches, new features, and package compatibility. Here's how to do it on any OS in under 10 minutes.

Quick answer: If you have nvm installed, run nvm install --lts && nvm use --lts. On macOS with Homebrew, run brew upgrade node. Otherwise, download the latest LTS installer from nodejs.org.

📋 Before You Update

✅ Rule: Always update to the LTS version unless you need a specific feature from Current.

1

Method A — Using nvm (Recommended)

nvm (Node Version Manager) is the best way to update Node because it lets you switch versions freely.

# Install the latest LTS version
nvm install --lts

# Use it as the default
nvm use --lts
nvm alias default lts/*

# Verify
node --version

Don't have nvm? Install it first — see our Install Node.js guide.

2

Method B — Using npm

If you don't have nvm, you can try updating via npm — but this doesn't always work on all systems.

# Install latest LTS
npm install -g n
sudo n lts

# Or on Windows with npm-windows-upgrade
npm install -g npm-windows-upgrade
npm-windows-upgrade

💡 Note: The npm method may require sudo/admin rights and doesn't work on Windows the same way. Use nvm or the installer instead.

3

Method C — Using Homebrew (macOS/Linux)

If you installed Node via Homebrew:

brew update
brew upgrade node

# Verify
node --version

Homebrew always gives you the latest LTS version.

4

Method D — Official Installer

The simplest method if you don't have nvm or Homebrew:

  1. Go to nodejs.org
  2. Download the latest LTS installer for your OS
  3. Run the installer — it will replace the old version automatically
  4. Restart your terminal
  5. Run node --version to verify

🔧 After Updating — Check These

🚫 Common Mistakes

❓ Frequently Asked Questions

How do I update Node.js?;

Easiest with nvm: nvm install --lts && nvm use --lts. On macOS with Homebrew: brew upgrade node.

Should I update to the latest version?

Update to the latest LTS version, not Current. LTS is stable and supported for 30 months.

Will updating break my projects?

It might. Each project can pin its own Node version via nvm. Test updates in a dev environment first.

What is the latest Node.js version?

Check nodejs.org for the current LTS. As of 2026, Node 22 is the LTS.

🎯 What's Next?

← All How-To Guides