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 installOptions
--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-enabledUsage 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.xInstall Specific Version
bash
# Install major version
fnm install 20
# Install minor version
fnm install 20.10
# Install exact version
fnm install 20.10.0Install and Use
bash
# Install and switch immediately
fnm install 20 --use
# Install and set as default
fnm install 20 --use && fnm default 20Use Mirror for Faster Download
bash
# Use mirror
fnm install 20 --node-dist-mirror=https://npmmirror.com/mirrors/nodeInstall Specific Architecture
bash
# Install x64 version on Apple Silicon Mac
fnm install 20 --arch=x64Version Formats
fnm supports multiple version formats:
| Format | Example | Description |
|---|---|---|
| Major version | 20 | Latest 20.x.x |
| Minor version | 20.10 | Latest 20.10.x |
| Exact version | 20.10.0 | Exact version |
| LTS name | lts/iron | LTS version codename |
| latest | --latest | Latest version |
LTS Version Codenames
| Codename | Version | Release Date |
|---|---|---|
| Iron | 20.x | 2023-10 |
| Hydrogen | 18.x | 2022-10 |
| Gallium | 16.x | 2021-10 |
| Erbium | 14.x | 2020-10 |
| Dubnium | 12.x | 2019-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=~/.fnmCommon 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=infoVersion Already Exists
bash
# View installed versions
fnm list
# Use installed version
fnm use 20Slow Download
bash
# Configure mirror
export FNM_NODE_DIST_MIRROR=https://npmmirror.com/mirrors/node
fnm install 20Related Links
- Install Node.js - Installation guide
- Command Reference - All command details
- Download Management - Download configuration