fnm

Fast Node Manager — install, switch, and manage Node.js versions from the command line.

cli
fnmnodenodejsversion-managernvm

Commands Reference

CommandAliasDescription
fnm install [version]fnm iInstall a Node.js version
fnm use [version]Switch to a Node.js version
fnm listfnm lsList locally installed versions
fnm list-remotefnm ls-remoteList all available remote versions
fnm currentPrint the active Node.js version
fnm default [version]Set or get the default version
fnm alias <version> <name>Create a named alias for a version
fnm unalias <name>Remove a named alias
fnm uninstall [version]fnm uniUninstall a Node.js version
fnm exec [args...]Run a command inside a specific Node.js context
fnm envPrint shell environment setup for fnm
fnm completionsPrint shell completions to stdout

Installation

# macOS / Linux via curl
curl -fsSL https://fnm.vercel.app/install | bash

# macOS via Homebrew
brew install fnm

# Windows via winget
winget install Schniz.fnm

# Windows via Chocolatey
choco install fnm

Shell Setup

# Bash — add to ~/.bashrc
eval "$(fnm env --use-on-cd --version-file-strategy=recursive)"

# Zsh — add to ~/.zshrc
eval "$(fnm env --use-on-cd --version-file-strategy=recursive)"

# Fish — add to ~/.config/fish/config.fish
fnm env --use-on-cd --version-file-strategy=recursive | source

# PowerShell — add to $PROFILE
fnm env --use-on-cd --version-file-strategy=recursive | Out-String | Invoke-Expression

Installing Node.js

fnm install 20          # Install Node.js v20 (latest minor)
fnm install 20.11.0     # Install exact version
fnm install --lts       # Install latest LTS release
fnm install --latest    # Install latest available version
fnm install lts/iron    # Install by LTS codename

fnm install 20 --use    # Install and switch to it immediately

Switching Versions

fnm use 20              # Switch to Node.js v20
fnm use 18.12.0         # Switch to exact version
fnm use lts/hydrogen    # Switch to LTS codename
fnm use --install-if-missing 22  # Install first if not present

Listing Versions

fnm list                # List locally installed versions
fnm ls                  # Alias for list

fnm list-remote         # List all available remote versions
fnm ls-remote           # Alias for list-remote
fnm ls-remote --lts     # Show only LTS versions
fnm ls-remote --filter 20  # Filter by version
fnm ls-remote --latest  # Show only the latest matching version
fnm ls-remote --sort=desc  # Sort from latest to earliest

Aliases & Defaults

fnm alias 20.11.0 myalias    # Create alias for a version
fnm unalias myalias           # Remove an alias

fnm default 20               # Set v20 as the default version
fnm default                  # Print current default version

Current Version

fnm current             # Print the active Node.js version
node --version          # Confirm via node itself

Run Command in Version Context

fnm exec --using=18 node --version   # Run node v18 without switching
fnm exec --using=20 npm install      # Run npm with a specific Node version

Auto-Switching with Version Files

# fnm reads .node-version or .nvmrc automatically when --use-on-cd is set
echo "20" > .node-version    # Project requests Node v20
echo "lts/iron" > .nvmrc     # Or using LTS codename

cd my-project                # fnm switches automatically on cd

Configuration (Shell Flags)

# --use-on-cd: auto-switch version when changing directories (recommended)
eval "$(fnm env --use-on-cd)"

# --version-file-strategy=recursive: search parent dirs for .node-version / .nvmrc (recommended)
eval "$(fnm env --version-file-strategy=recursive)"

# --resolve-engines: use engines.node in package.json as version file (experimental)
eval "$(fnm env --resolve-engines)"

# --corepack-enabled: run `corepack enable` on each new Node install (experimental)
eval "$(fnm env --corepack-enabled)"

# Combine recommended flags
eval "$(fnm env --use-on-cd --version-file-strategy=recursive)"

Environment Variables

FNM_DIR=/path/to/dir          # Root directory for fnm installations
FNM_NODE_DIST_MIRROR=https://npmmirror.com/mirrors/node  # Custom Node dist mirror
FNM_LOGLEVEL=quiet            # Log level: quiet | error | info
FNM_ARCH=x64                  # Override binary architecture
FNM_VERSION_FILE_STRATEGY=recursive  # local | recursive
FNM_COREPACK_ENABLED=true     # Enable corepack on install
FNM_RESOLVE_ENGINES=true      # Use package.json engines.node

Shell Completions

fnm completions --shell bash    # Generate Bash completions
fnm completions --shell zsh     # Generate Zsh completions
fnm completions --shell fish    # Generate Fish completions
fnm completions --shell powershell  # Generate PowerShell completions

# Install Zsh completions
fnm completions --shell zsh > ~/.zfunc/_fnm

Uninstalling Versions

fnm uninstall 18.12.0   # Remove a specific version
fnm uni 16              # Alias for uninstall
# Note: removing an alias target also removes all aliases pointing to it