2 min read

Install Node.js and npm

Install Node.js and npm via a version manager (nvm, fnm, or Volta) so you can switch versions per project. Verify with node -v and npm -v.

Install Node.js and npm

Don't install Node.js from the official .pkg or .msi installer. Use a version manager so you can switch between Node versions per project — every JS project pins a different one, and a global system Node will fight you the first time you join a team. This post covers fnm (my pick) with notes on nvm and Volta.

npm comes bundled with Node, so installing Node installs npm. No separate step.

macOS and Linux: fnm

Fnm (Fast Node Manager) is written in Rust, fast, and works on macOS, Linux, and Windows.

# install fnm via homebrew on macos

brew install fnm

On Linux:

# install fnm via the official script on linux

curl -fsSL https://fnm.vercel.app/install | bash

After install, add the shell hook (zsh or bash):

# load fnm in your shell

echo 'eval "$(fnm env --use-on-cd)"' >> ~/.zshrc && source ~/.zshrc

Now install a Node version and use it as default:

# install the current LTS

fnm install --lts
# set the LTS as default for new shells

fnm default lts-latest

If you don't have Homebrew yet, see Install Homebrew.

Windows

Use fnm via winget:

# install fnm on windows via winget

winget install Schniz.fnm

Add the PowerShell hook (one-time):

# add fnm hook to powershell profile

fnm env --use-on-cd | Out-String | Invoke-Expression

For a permanent setup add the same line to $PROFILE.

Alternatives

  • nvm — bash-only, slower than fnm, doesn't work on Windows native (use nvm-windows there). Mature and most-documented.
  • Volta — handles Node, npm, yarn, pnpm. Pins versions per project via package.json. Good for monorepos.
  • System install — possible via brew (brew install node) or apt, but you'll regret it the first time a project pins Node 18 and another pins 22.

Verify

# check node and npm versions

node -v && npm -v

You should see two version strings, e.g. v22.4.0 and 10.8.1. The npm version trails Node major versions — that's normal.

Common gotchas

  • Permission errors on npm install -g: classic sign of a system Node. The fix is to switch to a version manager, not sudo npm install. sudo makes the problem permanent.
  • .nvmrc / .node-version files: project-pinned Node versions. With fnm env --use-on-cd, cd-ing into the project auto-switches.
  • Corepack: Node 16+ ships with corepack, which manages yarn and pnpm. Enable with corepack enable. You don't need to npm install -g yarn anymore.

With Node and npm working you're ready to install JS-based tools (Anthropic SDK, OpenAI SDK, build tools) without polluting a global system path.

Rate this article

How helpful did you find this?

Newsletter

Get new articles in your inbox

AI engineering, LLM systems, and software architecture — no filler.

No spam. Unsubscribe any time.

Discussion

Comments

Leave a note about the article, architecture choices, or what you would build next.

Comments are stored in Supabase and fetched per post slug.

Loading comments...