Skip to content

Install fnm

fnm offers multiple installation methods. Choose the one that suits your operating system.

macOS

bash
brew install fnm

Using curl Script

bash
curl -fsSL https://fnm.vercel.app/install | bash

Using MacPorts

bash
port install fnm

Windows

powershell
winget install Schniz.fnm

Using Scoop

powershell
scoop install fnm

Using Chocolatey

powershell
choco install fnm

Using curl Script (Requires Git Bash or WSL)

bash
curl -fsSL https://fnm.vercel.app/install | bash

Linux

bash
curl -fsSL https://fnm.vercel.app/install | bash

Using Homebrew

bash
brew install fnm

Download from GitHub Releases

  1. Visit fnm Releases page
  2. Download the archive for your architecture
  3. 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/fnm

Configure 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 ~/.bashrc

Zsh

Add the following to ~/.zshrc:

zsh
eval "$(fnm env --use-on-cd)"

Then reload the configuration:

zsh
source ~/.zshrc

Fish

Add the following to ~/.config/fish/config.fish:

fish
fnm env --use-on-c | source

Then reload the configuration:

fish
source ~/.config/fish/config.fish

PowerShell

Add the following to the PowerShell profile:

powershell
fnm env --use-on-cd | Out-String | Invoke-Expression

You can open the profile with:

powershell
notepad $PROFILE

Verify Installation

After installation, verify that fnm is installed correctly:

bash
fnm --version

Output similar to:

fnm 1.37.1

Environment Variable Configuration

fnm supports the following environment variables for custom configuration:

Environment VariableDescriptionDefault
FNM_DIRfnm installation directory~/.fnm
FNM_NODE_DIST_MIRRORNode.js download mirrorhttps://nodejs.org/dist
FNM_LOGLEVELLog levelinfo
FNM_ARCHArchitecture overrideSystem architecture
FNM_COREPACK_ENABLEDEnable Corepackfalse

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/node

Or 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: