Why I Switched From nvm to fnm for Node Version Management

My terminal took the better part of a second to become usable, and I finally traced most of that lag to nvm. That, plus the daily friction of typing nvm use in every project, is why I moved to fnm.

This is a field note, not a crusade. nvm is a perfectly good tool that has managed Node versions on millions of machines for a decade. But it is a shell script, sourced into every interactive shell you open, and on a developer laptop that runs a new shell dozens of times a day the cost adds up. fnm is a single compiled binary written in Rust. The switch took ten minutes, removed the startup lag, and gave me automatic version switching per directory as a bonus. Here is exactly what changed and how to reproduce it.

The two problems that made me move

Shell startup. nvm works by sourcing a large shell function into your .bashrc or .zshrc. Every new interactive shell re-runs that initialisation, and if you have lazy-loading workarounds bolted on you already know the smell of the problem. fnm ships as a binary that you invoke once to print an environment block; the shell only evaluates that small block, not a multi-hundred-line script. If you want the actual number on your own machine rather than taking my word for it, measure it with hyperfine and compare a shell with each manager initialised. Do the measurement before you decide — startup cost is estate-specific.

Free · 4 minutes

Is your engineering team shipping safely, or quietly accumulating risk?

Fourteen questions on how work gets from idea to production — cadence, testing, rollback, and the key-person risk in your delivery. Banded finding on screen, full sheet by email.

Manual switching. With nvm I typed nvm use on entering a project, or I forgot to, and then built against the wrong Node. fnm reads a project’s .node-version or .nvmrc and switches automatically when I change into the directory. That single behaviour has removed a whole class of “works on my machine” confusion from my week.

Installing and wiring it into the shell

Install fnm (Homebrew on macOS, winget or Scoop on Windows, the install script or Cargo on Linux), then add its environment block to your shell profile. The important flag is --use-on-cd, which is what installs the directory-change hook. Here is the bash and zsh setup:

# ~/.bashrc or ~/.zshrc
# Evaluate fnm's environment once per shell.
# --use-on-cd installs the hook that reads .node-version / .nvmrc on cd.
eval "$(fnm env --use-on-cd)"

Fish uses a slightly different form, because it does not evaluate POSIX shell:

# ~/.config/fish/config.fish
fnm env --use-on-cd | source

Open a new shell, install an LTS and pin it globally:

# Install and use the current LTS (Node 22 "Jod" at time of writing)
fnm install --lts
fnm use lts-latest
fnm default lts-latest

node --version   # v22.x.x

Then, in each project, drop a version file so fnm knows what to switch to. A .node-version file is the more portable choice — several tools read it, whereas .nvmrc is nvm’s own convention. fnm honours both:

# Pin this repository to Node 22
node --version | sed 's/^v//' > .node-version
cat .node-version   # 22.x.x

# Now leaving and re-entering the directory auto-switches:
cd .. && cd -

If you keep monorepos or nested packages, add --version-file-strategy=recursive to the fnm env call so a nested directory inherits the version file from a parent. The default is local, which only looks in the current directory.

The corepack and pnpm interaction

This is the part people trip over. corepack is Node’s built-in shim for pnpm and Yarn: it reads the packageManager field in package.json and provisions the right version. Because fnm installs a fresh, isolated Node for each version, corepack is not necessarily enabled in that install, and each new Node you install starts clean.

Two ways to handle it. The manual route is to run corepack enable once per installed Node version. The tidier route is fnm’s experimental --corepack-enabled flag, which runs corepack enable automatically whenever fnm installs a Node version:

# Enable corepack for the Node version currently in use
corepack enable

# Or have fnm do it on every install (experimental flag):
# eval "$(fnm env --use-on-cd --corepack-enabled)"

# In package.json, pin the package manager so corepack provisions it:
#   "packageManager": "pnpm@9.12.0"
pnpm --version

One more experimental option worth knowing: --resolve-engines tells fnm to treat package.json#engines#node as a valid version specifier, so a repo that declares its Node range in engines rather than a version file still switches correctly. Treat both experimental flags as exactly that — confirm the behaviour on your fnm version before you standardise a team on them. This is the same discipline I apply to Python CLI tooling with pipx: pin the version, know what the shim is doing, don’t let it be magic.

Where nvm still fits

I am not telling you to rip nvm out of every machine. If a build server or a colleague’s environment is already stable on nvm, the marginal gain from switching is small and change carries its own risk. nvm’s .nvmrc ecosystem is mature, its nvm install-latest-npm helper has no direct fnm equivalent, and on a CI box that spins up one shell per job the startup cost is irrelevant. fnm earns its place on the interactive developer laptop — the machine that opens hundreds of shells a day and hops between projects on different Node versions.

The broader point is the one I keep coming back to in these operational field notes: the tools underneath your delivery process are not neutral. A slow shell is a small tax paid hundreds of times a day, and the wrong Node version silently building is exactly the kind of environment drift that a disciplined, contract-first workflow is supposed to eliminate. Pin the version in the repository, let the tool switch automatically, and stop typing nvm use into the void.

Free interactive tool

Website compliance checklist

What your site has to do, based on what it actually does

Answer as much or as little as you like — the list builds as you go. Nothing is stored against your name and no email is required.

Most technology problems are not technology problems. They are control problems.

The systems exist. The investment has been made. The question is whether leadership can understand, direct, evidence, and sustain what those systems produce. Find out where control exists — and where it only appears to.