How to Fix nvm command not found Error
DodaTech
1 min read
In this tutorial, you'll learn about How to Fix nvm command not found Error. We cover key concepts, practical examples, and best practices.
The Problem
You open a new terminal and type nvm:
nvm: command not found
Or:
bash: nvm: command not found
nvm is a shell function, not a standalone binary. New terminal sessions do not load it automatically unless the sourcing line is in your shell profile.
Quick Fix
Step 1: Source nvm manually
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
Now nvm should work in the current session.
Step 2: Add nvm to your shell profile
Make the sourcing permanent by adding it to your shell configuration:
Bash:
echo 'export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> ~/.bashrc
source ~/.bashrc
Zsh:
echo 'export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> ~/.zshrc
source ~/.zshrc
Step 3: Reinstall nvm if missing
If ~/.nvm/nvm.sh does not exist, reinstall nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
Close and reopen your terminal, then verify:
nvm --version
Expected output:
0.40.0
Alternative Solutions
Use fnm (Fast Node Manager) as a faster alternative:
curl -fsSL https://fnm.vercel.app/install | bash
fnm install --lts
Prevention
- Add nvm sourcing to your shell profile immediately after installation.
- Use
.nvmrcfiles in projects sonvm useworks automatically. - Check that
~/.bashrc(not~/.bash_profile) is being sourced.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro