bash: command not found — how to fix
Quick Answer
# Check if the command exists anywhere on the system
which node # shows path if found
command -v node # POSIX-compatible version
type node # also shows if it's an alias or function
# Check your PATH
echo $PATH
# If you just installed something, reload your shell config
source ~/.bashrc # bash
source ~/.zshrc # zsh
When this happens
bash: node: command not found
# or
zsh: command not found: python
The shell cannot find the program in any directory listed in $PATH.
Other causes & fixes
Add a directory to PATH
# Temporarily (current session only)
export PATH="$HOME/.local/bin:$PATH"
# Permanently — add to ~/.bashrc or ~/.zshrc
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
Install the missing command (Ubuntu/Debian)
# Search for which package provides a command
apt-cache search node
sudo apt install nodejs
# Or use apt-file
sudo apt install apt-file
apt-file search bin/node
Version manager installed but not initialised
Tools like nvm, rbenv, pyenv need to be initialized in your shell profile.
# nvm — add to ~/.bashrc or ~/.zshrc
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh"
# Then reload
source ~/.bashrc
Related