React SME Cookbook
All FAQs
nodejsnpmnvminstallltsmacoswindows

Installing Node.js and npm

How to download and install Node.js and npm on macOS and Windows — including what LTS means, the different installation methods, and which one to pick.

Recipe

Quick-reference recipe card — copy-paste ready.

# Check if Node.js is already installed
node --version
 
# Check npm version
npm --version
 
# Install Node.js via nvm (recommended for macOS/Linux)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
nvm install --lts
nvm use --lts
 
# Verify installation
node --version   # e.g. v22.15.0
npm --version    # e.g. 10.9.2

When to reach for this: Before starting any React, Next.js, or Node.js project you need Node.js and npm installed. This is always step zero.

PlatformLinkNotes
Official downloadshttps://nodejs.org/en/downloadInstallers for all platforms
macOS / Linux (nvm)https://github.com/nvm-sh/nvmVersion manager — recommended
Windows (nvm-windows)https://github.com/coreybutler/nvm-windowsWindows-specific version manager
macOS (Homebrew)brew install nodeSingle version via Homebrew
Windows (winget)winget install OpenJS.NodeJS.LTSSingle version via winget
Windows (Chocolatey)choco install nodejs-ltsSingle version via Chocolatey
Voltahttps://volta.shCross-platform version manager
fnmhttps://github.com/Schniz/fnmFast, Rust-based version manager

Always download from nodejs.org or a trusted version manager. The download page offers two tracks: LTS and Current.

Deep Dive

What Is LTS?

LTS stands for Long Term Support. Node.js follows a release schedule where even-numbered major versions (18, 20, 22, 24...) enter LTS status and receive bug fixes and security patches for 30 months. Odd-numbered versions (19, 21, 23...) are short-lived "Current" releases that only get support for 6 months.

TrackExampleSupport WindowBest For
LTSNode 22.x30 months of patchesProduction apps, teams, stability
CurrentNode 23.x~6 monthsTesting new features early

Rule of thumb: Always use the latest LTS version unless you have a specific reason to run Current. Every production deployment, CI pipeline, and tutorial in this cookbook assumes LTS.

What Is npm?

npm (Node Package Manager) is the default package manager that ships bundled with every Node.js installation. It does three things:

  1. Installs packages from the npm registry (the largest software registry in the world — over 2 million packages).
  2. Manages dependencies via package.json and package-lock.json.
  3. Runs scripts defined in package.json (e.g., npm run dev, npm test).

When you install Node.js, you get npm for free. You do not need to install it separately.

# Install a package
npm install react
 
# Install dev dependencies
npm install --save-dev typescript
 
# Run a script from package.json
npm run dev
 
# Install all dependencies from package.json
npm install

Installing on macOS

nvm (Node Version Manager) lets you install and switch between multiple Node.js versions. This is the best option for developers who work across projects that may require different Node versions.

# Install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
 
# Restart your terminal, then:
nvm install --lts        # Install latest LTS
nvm use --lts            # Activate it
nvm alias default lts/*  # Make it the default for new shells
 
# Switch between versions
nvm install 20           # Install Node 20
nvm use 20               # Switch to Node 20
nvm ls                   # List installed versions

nvm installs Node.js into ~/.nvm/ so it does not require sudo and avoids permission issues with global packages.

Option 2: Homebrew

brew install node        # Installs latest current version
brew install node@22     # Installs a specific LTS version

Simple, but only manages one version at a time. If you need to switch between versions, use nvm instead.

Option 3: fnm (fast alternative)

brew install fnm
fnm install --lts
fnm use --lts
 
# Add to shell profile (~/.zshrc or ~/.bashrc)
eval "$(fnm env --use-on-cd)"

fnm is written in Rust and is noticeably faster than nvm for version switching. It also supports .node-version and .nvmrc files.

Option 4: Volta

curl https://get.volta.sh | bash
volta install node@lts

Volta pins tool versions per-project in package.json so every contributor uses the same version automatically.

Option 5: Official installer

Download the .pkg file from https://nodejs.org/en/download and run it. Installs Node.js and npm system-wide into /usr/local/. Works, but harder to manage multiple versions and may require sudo for global installs.

Installing on Windows

nvm-windows is a separate project from nvm (not a port) but provides the same version-switching workflow.

  1. Download the installer from https://github.com/coreybutler/nvm-windows/releases
  2. Run the .exe installer
  3. Open a new terminal (Command Prompt or PowerShell):
nvm install lts          # Install latest LTS
nvm use lts              # Activate it
nvm list                 # List installed versions

Option 2: winget (Windows Package Manager)

winget install OpenJS.NodeJS.LTS

Built into Windows 11 and available for Windows 10. Installs a single version system-wide.

Option 3: Chocolatey

choco install nodejs-lts

Requires Chocolatey to be installed first. Similar to Homebrew on macOS — manages one version at a time.

Option 4: fnm

winget install Schniz.fnm
fnm install --lts
fnm use --lts

Works on Windows, macOS, and Linux. Fast version switching.

Option 5: Volta

# Download installer from https://volta.sh
volta install node@lts

Option 6: Official installer

Download the .msi file from https://nodejs.org/en/download and run it. Installs Node.js, npm, and optionally adds to PATH. Simplest option but hardest to manage multiple versions.

Which Method Should You Pick?

SituationRecommended Method
Multiple projects, different Node versionsnvm (macOS/Linux) or nvm-windows
Want the fastest version switchingfnm
Team needs everyone on same versionVolta
Just need Node.js installed quicklyHomebrew / winget / official installer
CI/CD pipelineOfficial installer or Docker node:22-alpine

Verifying Your Installation

After installing, open a new terminal and run:

node --version
# v22.15.0 (or similar LTS version)
 
npm --version
# 10.9.2 (or similar)
 
# Quick smoke test — run a one-liner
node -e "console.log('Node.js is working!')"

Keeping Node.js Updated

# With nvm
nvm install --lts --reinstall-packages-from=current
nvm use --lts
 
# With Homebrew
brew upgrade node
 
# With fnm
fnm install --lts
fnm use --lts
 
# With Volta
volta install node@lts

When upgrading Node.js, globally installed npm packages may need to be reinstalled. The --reinstall-packages-from=current flag in nvm handles this automatically.

Gotchas

  1. Forgetting to open a new terminal. After installing nvm or any version manager, your current shell does not pick up the new PATH entries. Always open a fresh terminal window.
  2. Permission errors with global installs. If you installed Node.js via the official installer and npm install -g fails with EACCES, switch to nvm — it installs into your home directory and avoids permission issues entirely. Never use sudo npm install -g.
  3. Multiple version managers fighting. If you have both nvm and Homebrew's Node.js installed, your PATH determines which one wins. Pick one method and uninstall the other.
  4. .nvmrc not auto-switching. nvm does not auto-switch Node versions when you cd into a directory with .nvmrc by default. Add autoload to your shell config or use fnm/Volta which do this out of the box.
  5. npm vs npx confusion. npm installs and manages packages. npx runs a package binary without installing it globally (e.g., npx create-next-app). Both ship with Node.js.
  6. Windows PATH issues. On Windows, if node is not recognized after installation, check that the install directory was added to your system PATH. Restart your terminal or log out and back in.
  7. Node.js version mismatch in VS Code terminal. VS Code may use a different shell profile than your regular terminal. If node --version shows a different version in VS Code, restart VS Code after installing or switching versions.

FAQs

What version of Node.js should I install?

Always install the latest LTS version unless a project specifies otherwise. LTS versions receive security patches and bug fixes for 30 months, making them the safe choice for production work and learning.

Do I need to install npm separately?

No. npm is bundled with Node.js. When you install Node.js, npm is included automatically. You can verify with npm --version.

What is the difference between npm and npx?

npm installs and manages packages. npx executes a package binary — either from your local node_modules/.bin or by temporarily downloading it. For example, npx create-next-app runs the create-next-app generator without installing it globally.

Should I use nvm or fnm?

Both work well. nvm is the most widely used and documented. fnm is faster (written in Rust) and supports auto-switching on cd out of the box. If speed matters to you, use fnm. If you want the broadest community support, use nvm.

Can I have multiple Node.js versions installed at the same time?

Yes, if you use a version manager (nvm, fnm, Volta, nvm-windows). They install each version in its own directory and let you switch between them with a single command. The official installer only manages one version.

What is a .nvmrc file?

A .nvmrc file in a project root contains the Node.js version that project expects (e.g., 22). When you run nvm use in that directory, nvm reads the file and switches to that version. fnm and Volta support similar files and can auto-switch when you cd into the directory.

How do I uninstall Node.js?

With nvm: nvm uninstall 20. With Homebrew: brew uninstall node. With the official installer on macOS, you need to manually remove files from /usr/local/. On Windows, use Add/Remove Programs.

Why does npm install -g fail with permission errors?

The official Node.js installer places files in system directories that require root access. The fix is to switch to nvm or fnm, which install into your home directory. Never use sudo npm install -g — it creates files owned by root that cause further permission issues.

Is Bun or Deno a replacement for Node.js?

Bun and Deno are alternative JavaScript runtimes. They can run many Node.js scripts but have different APIs and ecosystems. For React and Next.js development, Node.js remains the standard runtime. You can explore Bun or Deno for specific use cases, but start with Node.js.

How do I check which Node.js version a project requires?

Check the engines field in package.json (e.g., "engines": { "node": ">=20" }), look for a .nvmrc or .node-version file, or check the project README. If none exist, use the latest LTS version.