Skip to content

Uninstall fnm on Ubuntu

This guide provides detailed instructions on how to completely uninstall fnm on Ubuntu systems.

Quick Uninstall

Using the Uninstall Script

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

This script will:

  • Delete the fnm binary
  • Clean up the ~/.fnm directory
  • Prompt you to remove fnm-related code from your Shell configuration

Manual Uninstall Steps

Step 1: Delete fnm Directory

bash
rm -rf ~/.fnm

Step 2: Delete fnm Binary

Depending on the installation method, fnm may be located in different places:

bash
# If installed using curl script
rm -f ~/.fnm/fnm

# If manually installed to /usr/local/bin
sudo rm -f /usr/local/bin/fnm

# If installed using Homebrew
brew uninstall fnm

Step 3: Clean Shell Configuration

Bash

Edit ~/.bashrc:

bash
nano ~/.bashrc

Remove the following lines:

bash
eval "$(fnm env --use-on-cd)"
export PATH="$HOME/.fnm:$PATH"

Reload:

bash
source ~/.bashrc

Zsh

Edit ~/.zshrc:

bash
nano ~/.zshrc

Remove the following lines:

bash
eval "$(fnm env --use-on-cd)"
export PATH="$HOME/.fnm:$PATH"

Reload:

bash
source ~/.zshrc

Step 4: Clean Environment Variables

Check and clean related environment variables:

bash
# View current environment variables
env | grep FNM

# If there are leftovers, edit Shell configuration file to remove them

fnm Installed via apt

If you installed fnm via apt:

bash
# Find package name
dpkg -l | grep fnm

# Uninstall
sudo apt remove fnm
sudo apt autoremove

fnm Installed via Snap

If you installed via Snap:

bash
sudo snap remove fnm

Clean Node.js Versions

If you want to also delete Node.js versions managed by fnm:

bash
# Delete all Node.js versions
rm -rf ~/.fnm/node-versions

Keep Node.js Versions

If you want to keep installed Node.js versions:

bash
# Backup Node.js versions
cp -r ~/.fnm/node-versions ~/node-backup

# Or export to system path
sudo cp -r ~/.fnm/node-versions/v20.10.0/installation /usr/local/node20
sudo ln -s /usr/local/node20/bin/node /usr/local/bin/node

Verify Uninstall

bash
# Should output "command not found"
fnm --version

# Check if directory is deleted
ls ~/.fnm

# Check if fnm is still in PATH
echo $PATH | grep fnm

Common Issues

Slow Shell Startup After Uninstall

Check if there's leftover code in Shell configuration files:

bash
grep -r "fnm" ~/.bashrc ~/.zshrc ~/.profile 2>/dev/null

node Command Not Found

After uninstalling fnm, if there's no other Node.js installation:

bash
# Install system Node.js
sudo apt update
sudo apt install nodejs npm

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

PATH Issues

If there are still fnm-related paths in PATH:

bash
# Check PATH
echo $PATH

# Edit Shell configuration file to clean up
nano ~/.bashrc  # or ~/.zshrc

Reinstall

If you need to reinstall fnm:

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

# Configure Shell
echo 'eval "$(fnm env --use-on-cd)"' >> ~/.bashrc
source ~/.bashrc