Skip to content

fnm install Command Guide

The fnm install command is used to install new Node.js versions.

Command Syntax

bash
fnm install [OPTIONS] [VERSION]

Parameters

VERSION

Specify the Node.js version to install:

bash
# Install major version (automatically selects latest minor version)
fnm install 20

# Install specific version
fnm install 20.10.0

# Install LTS version
fnm install lts/iron

# No version specified, reads from version file
fnm install

Options

--lts

Install the latest LTS (Long Term Support) version:

bash
fnm install --lts

--latest

Install the latest version (including non-LTS):

bash
fnm install --latest

--use

Switch to the version immediately after installation:

bash
fnm install 20 --use

--progress

Control download progress bar display:

bash
# Auto display (default)
fnm install 20 --progress=auto

# Always display
fnm install 20 --progress=always

# Never display
fnm install 20 --progress=never

--node-dist-mirror

Specify Node.js download mirror:

bash
fnm install 20 --node-dist-mirror=https://npmmirror.com/mirrors/node

--arch

Specify the installation architecture:

bash
# Install x64 version
fnm install 20 --arch=x64

# Install ARM64 version
fnm install 20 --arch=arm64

--fnm-dir

Specify fnm installation directory:

bash
fnm install 20 --fnm-dir=/custom/path

--log-level

Set log level:

bash
fnm install 20 --log-level=quiet
fnm install 20 --log-level=error
fnm install 20 --log-level=info

--corepack-enabled

Enable Corepack support:

bash
fnm install 20 --corepack-enabled

Usage Examples

Install LTS Version

bash
# Install latest LTS
fnm install --lts

# Install specific LTS version
fnm install lts/iron    # Node.js 20.x
fnm install lts/hydrogen # Node.js 18.x

Install Specific Version

bash
# Install major version
fnm install 20

# Install minor version
fnm install 20.10

# Install exact version
fnm install 20.10.0

Install and Use

bash
# Install and switch immediately
fnm install 20 --use

# Install and set as default
fnm install 20 --use && fnm default 20

Use Mirror for Faster Download

bash
# Use mirror
fnm install 20 --node-dist-mirror=https://npmmirror.com/mirrors/node

Install Specific Architecture

bash
# Install x64 version on Apple Silicon Mac
fnm install 20 --arch=x64

Version Formats

fnm supports multiple version formats:

FormatExampleDescription
Major version20Latest 20.x.x
Minor version20.10Latest 20.10.x
Exact version20.10.0Exact version
LTS namelts/ironLTS version codename
latest--latestLatest version

LTS Version Codenames

CodenameVersionRelease Date
Iron20.x2023-10
Hydrogen18.x2022-10
Gallium16.x2021-10
Erbium14.x2020-10
Dubnium12.x2019-10

Environment Variables

You can configure default behavior through environment variables:

bash
# Set mirror
export FNM_NODE_DIST_MIRROR=https://npmmirror.com/mirrors/node

# Enable Corepack
export FNM_COREPACK_ENABLED=true

# Set installation directory
export FNM_DIR=~/.fnm

Common Issues

Installation Failed

bash
# Try using mirror
fnm install 20 --node-dist-mirror=https://npmmirror.com/mirrors/node

# View detailed logs
fnm install 20 --log-level=info

Version Already Exists

bash
# View installed versions
fnm list

# Use installed version
fnm use 20

Slow Download

bash
# Configure mirror
export FNM_NODE_DIST_MIRROR=https://npmmirror.com/mirrors/node
fnm install 20