2 min read

Install Node.js and npm without future regret

Install Node and npm through a version manager so you can switch versions per project. fnm is my pick, with nvm and Volta as alternatives.

Install Node.js and npm without future regret

Skip the official .pkg or .msi installer. I mean it.

This is post 3 of 10 in the Setup Toolbox series. Here's the problem with a global system Node: every JS project pins a different version, and the day you join a team is the day a single system Node starts fighting you. A version manager fixes that. You switch Node versions per project and move on with your life. This post covers fnm, which is my pick, with notes on nvm and Volta.

One thing up front. npm comes bundled with Node, so installing Node installs npm. There's no separate step.

macOS and Linux: fnm

Fnm (Fast Node Manager) is written in Rust, it's fast, and it runs 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 set it as your 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, and no native Windows support (use nvm-windows there). It's mature and the most documented.
  • Volta: handles Node, npm, yarn, and pnpm. Pins versions per project via package.json. Good for monorepos.
  • System install: possible via brew (brew install node) or apt. You'll regret it the first time one project pins Node 18 and another pins 22.

Verify

# check node and npm versions

node -v && npm -v

You should see two version strings, something like v22.4.0 and 10.8.1. The npm version trails Node major versions. That's normal, not a bug.

Common gotchas

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

With Node and npm working, you're set 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...