fnm use Command Guide
The fnm use command is used to switch the currently used Node.js version.
Command Syntax
bash
fnm use [OPTIONS] [VERSION]Parameters
VERSION
Specify the Node.js version to switch to:
bash
# Switch to major version
fnm use 20
# Switch to specific version
fnm use 20.10.0
# Use alias
fnm use default
# No version specified, reads from version file
fnm useOptions
--install-if-missing
Automatically install the version if not already installed:
bash
fnm use 18 --install-if-missing--silent-if-unchanged
Do not output message if version is unchanged:
bash
fnm use 20 --silent-if-unchanged--node-dist-mirror
Used with --install-if-missing to specify download mirror:
bash
fnm use 18 --install-if-missing --node-dist-mirror=https://npmmirror.com/mirrors/node--fnm-dir
Specify fnm installation directory:
bash
fnm use 20 --fnm-dir=/custom/path--log-level
Set log level:
bash
fnm use 20 --log-level=quietUsage Examples
Basic Switch
bash
# Switch to Node.js 20
fnm use 20
# Switch to Node.js 18.17.0
fnm use 18.17.0Auto Install and Switch
bash
# Automatically install if version is not installed
fnm use 16 --install-if-missingSwitch Using Alias
bash
# Use preset alias
fnm use default
fnm use legacySilent Mode
bash
# Use in scripts to avoid unnecessary output
fnm use 20 --silent-if-unchangedVersion Selection Priority
When no version is specified, fnm searches in the following order:
.node-versionfile.nvmrcfilepackage.jsonengines.node- Default version
Difference from default Command
fnm use- Switches version for current Shell sessionfnm default- Sets global default version
bash
# Set default version (affects new terminals)
fnm default 20
# Temporarily switch version (current terminal only)
fnm use 18Common Issues
Version Not Installed
bash
# Error message
error: Can't find version 18.0.0
# Solution: Auto install
fnm use 18 --install-if-missingnode Version Doesn't Change After Switch
Ensure Shell configuration is correct:
bash
# Check node path
which node
# Should point to fnm directory
# ~/.fnm/node-versions/.../bin/nodeVersion File Not Working
bash
# Confirm --use-on-cd is enabled
eval "$(fnm env --use-on-cd)"
# Confirm version file exists
cat .node-versionRelated Links
- Version Management - Version management guide
- Command Reference - All command details
- install Command - install command details