fnm Cheat Sheet
Overview
fnm (Fast Node Manager) is a fast, simple Node.js version manager built in Rust. It provides near-instant version switching, automatic per-directory version switching via .node-version and .nvmrc files, cross-platform support (macOS, Linux, Windows), and shell completions. fnm is significantly faster than nvm due to its compiled native binary.
fnm installs Node.js versions to an isolated directory and uses symlinks or PATH manipulation to switch between versions. It supports all major shells (bash, zsh, fish, PowerShell), integrates with Corepack for package manager management, and can be used in CI/CD pipelines for fast, reliable Node.js version management.
Installation
# macOS / Linux (curl)
curl -fsSL https://fnm.vercel.app/install | bash
# macOS via Homebrew
brew install fnm
# Linux via Snap
sudo snap install fnm
# Cargo (Rust)
cargo install fnm
# Windows via Chocolatey
choco install fnm
# Windows via Scoop
scoop install fnm
# Windows via winget
winget install Schniz.fnm
# Verify
fnm --version
Shell Setup
# Bash - add to ~/.bashrc
eval "$(fnm env --use-on-cd)"
# Zsh - add to ~/.zshrc
eval "$(fnm env --use-on-cd)"
# Fish - add to ~/.config/fish/config.fish
fnm env --use-on-cd | source
# PowerShell - add to profile
fnm env --use-on-cd | Out-String | Invoke-Expression
Core Commands
| Command | Description |
|---|---|
fnm install <version> | Install a Node.js version |
fnm use <version> | Switch to a version |
fnm default <version> | Set default version |
fnm current | Show current active version |
fnm list | List installed versions |
fnm list-remote | List available versions |
fnm uninstall <version> | Remove a version |
fnm alias <name> <version> | Create an alias |
fnm unalias <name> | Remove an alias |
fnm exec <command> | Run command with a specific version |
fnm env | Print environment variables for shell |
fnm completions | Generate shell completions |
Installing Node.js
# Install latest LTS
fnm install --lts
# Install latest version
fnm install latest
# Install specific version
fnm install 20.11.0
fnm install 18.19.0
# Install major version (latest patch)
fnm install 20
fnm install 22
# List available versions
fnm list-remote
# List only LTS versions
fnm list-remote --lts
Switching Versions
# Use a specific version
fnm use 20.11.0
fnm use 20
# Use latest LTS
fnm use --lts
# Use latest
fnm use latest
# Use system Node
fnm use system
# Set default version for new shells
fnm default 20.11.0
fnm default 20
# Check current version
fnm current
node --version
Automatic Version Switching
# Create .node-version file
echo "20" > .node-version
# Or .nvmrc (also supported)
echo "20.11.0" > .nvmrc
# With --use-on-cd in shell setup, fnm auto-switches
cd ~/project-a # Reads .node-version and switches
cd ~/project-b # Switches to that project's version
Supported Version File Formats
# .node-version or .nvmrc
20.11.0 # Exact version
20 # Latest 20.x.x
lts/* # Latest LTS
lts/iron # Specific LTS codename
latest # Latest stable
Aliases
# Create alias
fnm alias 20.11.0 my-project
# Use alias
fnm use my-project
# Set default via alias
fnm default my-project
# List aliases
fnm list
# Remove alias
fnm unalias my-project
Listing Versions
# List installed versions
fnm list
# List remote versions
fnm list-remote
# List remote LTS only
fnm list-remote --lts
# Filter remote versions
fnm list-remote | grep "^v22"
Running Commands
# Execute command with specific version
fnm exec --using=18 -- node --version
fnm exec --using=20 -- npm install
fnm exec --using=22 -- npx create-next-app@latest
# Run script with specific version
fnm exec --using=18 -- node server.js
Shell Completions
# Bash
fnm completions --shell bash > /etc/bash_completion.d/fnm
# Zsh
fnm completions --shell zsh > ~/.zfunc/_fnm
# Fish
fnm completions --shell fish > ~/.config/fish/completions/fnm.fish
# PowerShell
fnm completions --shell power-shell >> $PROFILE
Advanced Usage
CI/CD Integration
# GitHub Actions
name: CI
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: Schniz/fnm-action@v1
- run: fnm use --install-if-missing
- run: node --version
- run: npm ci && npm test
# CI script
curl -fsSL https://fnm.vercel.app/install | bash --skip-shell
export PATH="$HOME/.local/share/fnm:$PATH"
eval "$(fnm env)"
fnm install --lts
fnm use --lts
npm ci && npm test
Custom Installation Directory
# Set custom base directory
export FNM_DIR="$HOME/.fnm"
eval "$(fnm env --use-on-cd --fnm-dir=$HOME/.fnm)"
Multi-Shell Support
# fnm works the same across all shells
# Each shell session gets its own Node version
# Terminal 1:
fnm use 18
node --version # v18.x.x
# Terminal 2:
fnm use 22
node --version # v22.x.x
Corepack Integration
# Enable Corepack with fnm-managed Node
fnm use 20
corepack enable
# Now yarn and pnpm are managed by Corepack
yarn --version
pnpm --version
Configuration
# Environment variables
export FNM_DIR="$HOME/.local/share/fnm" # Installation directory
export FNM_MULTISHELL_PATH="..." # Multi-shell path (auto-set)
export FNM_NODE_DIST_MIRROR="..." # Custom download mirror
export FNM_ARCH="x64" # Architecture override
export FNM_VERSION_FILE_STRATEGY="local" # local or recursive
export FNM_COREPACK_ENABLED="true" # Enable Corepack support
export FNM_RESOLVE_ENGINES="true" # Resolve engines field
# Chinese mirror
export FNM_NODE_DIST_MIRROR="https://npmmirror.com/mirrors/node"
# Shell setup options
eval "$(fnm env --use-on-cd --shell zsh --version-file-strategy recursive)"
Troubleshooting
| Issue | Solution |
|---|---|
fnm: command not found | Add fnm to PATH; source shell profile |
| Auto-switch not working | Add --use-on-cd to shell setup; check .node-version exists |
| Version not found | Run fnm list-remote to check availability; install first |
| Slow version listing | Remote list is cached; use fnm list for installed versions |
| Global packages missing | Global packages are per-version; reinstall after switching |
| Conflicts with nvm | Remove nvm from shell profile; use only one version manager |
.nvmrc not detected | Set --version-file-strategy recursive for parent directory search |
| Permission errors | fnm installs to home directory; never use sudo |