Skip to content
Latchkey

fnm use: Usage, Options & Common CI Errors

fnm use selects a Node.js version with fnm, a fast Rust-based nvm alternative.

fnm (Fast Node Manager) is a quicker, cross-platform alternative to nvm. Like nvm it relies on shell integration, so CI must run eval "$(fnm env)" before fnm use will affect the active node.

What it does

fnm use <version> switches the active Node version for the current shell. fnm is a real binary (unlike nvm's shell function), but it still needs its shell hooks installed via eval "$(fnm env)" so PATH points at the selected version. With --use-on-cd it auto-switches based on .node-version/.nvmrc when you change directories.

Common usage

Terminal
eval "$(fnm env)"                               # set up the shell hooks
fnm install 20
fnm use 20
fnm use                                          # use .node-version / .nvmrc
eval "$(fnm env --use-on-cd)"                    # auto-switch on cd

Common errors in CI

If you skip eval "$(fnm env)", fnm use changes fnm's internal state but node still resolves to the system binary - the equivalent of nvm's not-sourced trap. "error: Can't find version \"20\"" means it is not installed (fnm install 20 first). "Can't find an installed Node version matching the requested one" with no arg means there is no .node-version/.nvmrc, or it lists an uninstalled version. As with nvm, each CI step is a new shell, so re-run eval "$(fnm env)" per step.

Options

ItemWhat it does
envPrint shell hooks (eval this first)
--use-on-cdAuto-switch when entering a directory
<version> / (no arg)Switch to version / to .node-version
install <version>Install a Node version

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →