Skip to content

fnm Command Reference

fnm provides a concise and powerful set of command-line tools to manage Node.js versions.

Command Overview

fnm [OPTIONS] <COMMAND>

Global Options

OptionDescriptionDefault
--node-dist-mirror <URL>Node.js download mirrorhttps://nodejs.org/dist
--fnm-dir <DIR>fnm installation directory~/.fnm
--log-level <LEVEL>Log levelinfo
--arch <ARCH>Architecture overrideSystem architecture
--version-file-strategy <STRATEGY>Version file parsing strategylocal
--corepack-enabledEnable Corepackfalse
--resolve-enginesResolve engines.node in package.jsontrue

Core Commands

fnm install

Install new Node.js versions.

bash
fnm install [OPTIONS] [VERSION]

Parameters:

  • VERSION - Version number, can be partial semver or LTS version name (e.g., lts/iron)

Options:

  • --lts - Install latest LTS version
  • --latest - Install latest version
  • --use - Use the version immediately after installation
  • --progress <auto|never|always> - Display download progress bar

Examples:

bash
# fnm version
fnm --version


# Install latest LTS version
fnm install --lts

# Install latest version
fnm install --latest

# Install specific version
fnm install 20
fnm install 18.17.0

# Install specific LTS version
fnm install lts/iron

# Install and use immediately
fnm install 20 --use

fnm use

Switch Node.js version.

bash
fnm use [OPTIONS] [VERSION]

Options:

  • --install-if-missing - Automatically install if version is not installed
  • --silent-if-unchanged - Do not output message if version is unchanged

Examples:

bash
# Use specific version
fnm use 20

# Use latest installed version
fnm use

# Auto install if not installed
fnm use 18 --install-if-missing

fnm list

List locally installed Node.js versions.

bash
fnm list [OPTIONS]

Alias: ls

Example:

bash
fnm list

Output example:

* v20.10.0 default
  v18.19.0
  v16.20.2

fnm list-remote

List all available remote Node.js versions.

bash
fnm list-remote [OPTIONS]

Alias: ls-remote

Options:

  • --filter <FILTER> - Filter by version number or semver range
  • --lts [<NAME>] - Show only LTS versions
  • --latest - Show only latest versions
  • --sort <asc|desc> - Sort order

Examples:

bash
# List all versions
fnm list-remote

# List only LTS versions
fnm list-remote --lts

# List specific LTS version
fnm list-remote --lts=iron

# Filter versions
fnm list-remote --filter=18

# Show only latest versions
fnm list-remote --latest

fnm uninstall

Uninstall Node.js version.

bash
fnm uninstall [OPTIONS] [VERSION]

Alias: uni

Examples:

bash
# Uninstall specific version
fnm uninstall 16.20.2

# Uninstall via alias
fnm uninstall default

WARNING

If an alias is provided, fnm will delete the Node.js version that alias points to, as well as other aliases pointing to the same version.

Version Management Commands

fnm default

Set or get the default Node.js version.

bash
fnm default [VERSION]

Examples:

bash
# Set default version
fnm default 20

# Get current default version
fnm default

fnm current

Display the currently used Node.js version.

bash
fnm current

Example:

bash
fnm current
# Output: v20.10.0

fnm alias

Set an alias for a version.

bash
fnm alias <VERSION> <NAME>

Examples:

bash
# Set alias
fnm alias 20 default
fnm alias 18 legacy

# Use alias
fnm use default

fnm unalias

Delete an alias.

bash
fnm unalias <NAME>

Example:

bash
fnm unalias legacy

Environment Configuration Commands

fnm env

Output Shell environment variable configuration.

bash
fnm env [OPTIONS]

Options:

  • --shell <bash|zsh|fish|powershell> - Specify Shell type
  • --json - Output in JSON format
  • --use-on-cd - Output auto version switching script

Examples:

bash
# Output current Shell configuration
fnm env

# Output Bash configuration
fnm env --shell bash

# Output JSON format
fnm env --json

# Enable auto version switching
fnm env --use-on-cd

fnm completions

Output Shell completion script.

bash
fnm completions [OPTIONS]

Options:

  • --shell <bash|zsh|fish|powershell> - Specify Shell type

Examples:

bash
# Bash
fnm completions --shell bash >> ~/.bashrc

# Zsh
fnm completions --shell zsh >> ~/.zshrc

# Fish
fnm completions --shell fish > ~/.config/fish/completions/fnm.fish

# PowerShell
fnm completions --shell powershell >> $PROFILE

Advanced Commands

fnm exec

Execute a command in a specified Node.js version environment.

bash
fnm exec [OPTIONS] -- <COMMAND>

Options:

  • --using <VERSION> - Specify the version to use

Examples:

bash
# Execute command using Node.js 18
fnm exec --using=18 -- node --version

# Run script using specific version
fnm exec --using=20 -- npm run build

Command Cheat Sheet

CommandAliasDescription
installiInstall Node.js version
use-Switch Node.js version
listlsList installed versions
list-remotels-remoteList remote versions
uninstalluniUninstall Node.js version
default-Set/get default version
current-Show current version
alias-Set version alias
unalias-Delete alias
env-Output environment configuration
completions-Output completion script
exec-Execute command in specified version