Install fnm on Linux
fnm has multiple installation methods on Linux. This guide will help you install fnm on various Linux distributions.
Installation Methods
Using curl Script (Recommended)
The simplest installation method:
bash
curl -fsSL https://fnm.vercel.app/install | bashAfter installation, follow the prompts to reload Shell or manually add to PATH:
bash
export PATH="$HOME/.fnm:$PATH"
eval "$(fnm env --use-on-cd)"Using Homebrew
If you have Homebrew installed on Linux:
bash
brew install fnmManual Download
- Visit fnm Releases page
- Download the archive for your architecture:
bash
# x86_64
wget https://github.com/Schniz/fnm/releases/latest/download/fnm-linux.zip
# ARM64
wget https://github.com/Schniz/fnm/releases/latest/download/fnm-arm64.zip- Extract and install:
bash
unzip fnm-linux.zip -d ~/.local/bin
chmod +x ~/.local/bin/fnmDistribution-Specific Installation Guide
Ubuntu / Debian
bash
# Method 1: Using curl script
curl -fsSL https://fnm.vercel.app/install | bash
# Method 2: Manual installation
sudo apt update
sudo apt install -y unzip
wget https://github.com/Schniz/fnm/releases/latest/download/fnm-linux.zip
sudo unzip fnm-linux.zip -d /usr/local/bin
sudo chmod +x /usr/local/bin/fnmCentOS / RHEL / Fedora
bash
# Install dependencies
sudo dnf install -y unzip # Fedora
# or
sudo yum install -y unzip # CentOS/RHEL
# Using curl script
curl -fsSL https://fnm.vercel.app/install | bash
# Or manual installation
wget https://github.com/Schniz/fnm/releases/latest/download/fnm-linux.zip
sudo unzip fnm-linux.zip -d /usr/local/bin
sudo chmod +x /usr/local/bin/fnmArch Linux
bash
# Using AUR helper
yay -S fnm-bin
# Or build from AUR
git clone https://aur.archlinux.org/fnm-bin.git
cd fnm-bin
makepkg -siAlpine Linux
bash
# Install dependencies
apk add bash curl unzip
# Using curl script
curl -fsSL https://fnm.vercel.app/install | bash
# Or manual installation
wget https://github.com/Schniz/fnm/releases/latest/download/fnm-linux.zip
unzip fnm-linux.zip -d ~/.local/bin
chmod +x ~/.local/bin/fnmConfigure Shell
Bash
Edit ~/.bashrc:
bash
echo 'eval "$(fnm env --use-on-cd)"' >> ~/.bashrc
source ~/.bashrcZsh
Edit ~/.zshrc:
bash
echo 'eval "$(fnm env --use-on-cd)"' >> ~/.zshrc
source ~/.zshrcFish
Edit ~/.config/fish/config.fish:
fish
echo 'fnm env --use-on-c | source' >> ~/.config/fish/config.fish
source ~/.config/fish/config.fishShell Completion
Bash Completion
bash
# Install bash-completion (if not installed)
sudo apt install bash-completion # Debian/Ubuntu
sudo dnf install bash-completion # Fedora
# Add completion script
fnm completions --shell bash >> ~/.bashrc
source ~/.bashrcZsh Completion
bash
# Create completion directory
mkdir -p ~/.zsh/completions
# Generate completion script
fnm completions --shell zsh > ~/.zsh/completions/_fnm
# Add to ~/.zshrc
fpath=(~/.zsh/completions $fpath)
autoload -U compinit && compinitFish Completion
bash
fnm completions --shell fish > ~/.config/fish/completions/fnm.fishUsing Mirror in China
In mainland China, it's recommended to configure a mirror to accelerate downloads:
bash
# Add to Shell configuration file
export FNM_NODE_DIST_MIRROR=https://npmmirror.com/mirrors/node
# Or specify during eval
eval "$(fnm env --use-on-cd --node-dist-mirror=https://npmmirror.com/mirrors/node)"Common mirrors:
| Mirror Source | URL |
|---|---|
| npmmirror | https://npmmirror.com/mirrors/node |
| Tsinghua University | https://mirrors.tuna.tsinghua.edu.cn/nodejs-release |
| Huawei Cloud | https://mirrors.huaweicloud.com/nodejs |
Verify Installation
bash
# Check fnm version
fnm --version
# Install Node.js
fnm install --lts
# Verify Node.js
node --version
npm --versionCommon Issues
Command Not Found
bash
# Check if fnm is in PATH
which fnm
# Manually add to PATH
export PATH="$HOME/.fnm:$PATH"
# Permanently add to PATH
echo 'export PATH="$HOME/.fnm:$PATH"' >> ~/.bashrcPermission Issues
bash
# Ensure fnm has execute permission
chmod +x ~/.fnm/fnm
# or
chmod +x /usr/local/bin/fnmDownload Failed
bash
# Use mirror
export FNM_NODE_DIST_MIRROR=https://npmmirror.com/mirrors/node
fnm install --ltsNext Steps
After installation, you can:
- Install Node.js - Use fnm to install Node.js
- Command Reference - Learn all available commands
- Version Management - Learn version management
Related Links
- Install fnm - General installation guide
- Windows Installation - Windows installation guide
- macOS Installation - macOS installation guide
- Ubuntu Uninstall - Ubuntu uninstall guide