Install fnm
fnm offers multiple installation methods. Choose the one that suits your operating system.
macOS
Using Homebrew (Recommended)
bash
brew install fnmUsing curl Script
bash
curl -fsSL https://fnm.vercel.app/install | bashUsing MacPorts
bash
port install fnmWindows
Using winget (Recommended)
powershell
winget install Schniz.fnmUsing Scoop
powershell
scoop install fnmUsing Chocolatey
powershell
choco install fnmUsing curl Script (Requires Git Bash or WSL)
bash
curl -fsSL https://fnm.vercel.app/install | bashLinux
Using curl Script (Recommended)
bash
curl -fsSL https://fnm.vercel.app/install | bashUsing Homebrew
bash
brew install fnmDownload from GitHub Releases
- Visit fnm Releases page
- Download the archive for your architecture
- Extract and move the binary to a PATH directory
bash
# Example: Install x86_64 architecture
wget https://github.com/Schniz/fnm/releases/latest/download/fnm-linux.zip
unzip fnm-linux.zip -d /usr/local/bin
chmod +x /usr/local/bin/fnmConfigure Shell
After installation, you need to configure Shell environment variables.
Bash
Add the following to ~/.bashrc:
bash
eval "$(fnm env --use-on-cd)"Then reload the configuration:
bash
source ~/.bashrcZsh
Add the following to ~/.zshrc:
zsh
eval "$(fnm env --use-on-cd)"Then reload the configuration:
zsh
source ~/.zshrcFish
Add the following to ~/.config/fish/config.fish:
fish
fnm env --use-on-c | sourceThen reload the configuration:
fish
source ~/.config/fish/config.fishPowerShell
Add the following to the PowerShell profile:
powershell
fnm env --use-on-cd | Out-String | Invoke-ExpressionYou can open the profile with:
powershell
notepad $PROFILEVerify Installation
After installation, verify that fnm is installed correctly:
bash
fnm --versionOutput similar to:
fnm 1.37.1Environment Variable Configuration
fnm supports the following environment variables for custom configuration:
| Environment Variable | Description | Default |
|---|---|---|
FNM_DIR | fnm installation directory | ~/.fnm |
FNM_NODE_DIST_MIRROR | Node.js download mirror | https://nodejs.org/dist |
FNM_LOGLEVEL | Log level | info |
FNM_ARCH | Architecture override | System architecture |
FNM_COREPACK_ENABLED | Enable Corepack | false |
Using Mirror in China
In mainland China, you can configure a mirror to accelerate downloads:
bash
export FNM_NODE_DIST_MIRROR=https://npmmirror.com/mirrors/nodeOr add to Shell configuration file:
bash
eval "$(fnm env --use-on-cd --node-dist-mirror=https://npmmirror.com/mirrors/node)"Next Steps
After installation, you can:
- Install Node.js - Use fnm to install your first Node.js version
- Command Reference - Learn all available commands
- Version Management - Learn how to manage multiple Node.js versions