Claude Code fix: The shell answers command not found when you run claude

claude: command not found after installing Claude Code

claude command not found means your shell searched every directory on its PATH and none of them held a claude binary. Nearly always the install worked and one PATH line is missing: the native installer puts claude in ~/.local/bin on macOS and Linux and in %USERPROFILE%\.local\bin\claude.exe on Windows, and many shells never look there. The wording depends on the shell: zsh prints zsh: command not found: claude, bash prints bash: claude: command not found, CMD prints 'claude' is not recognized as an internal or external command, and PowerShell says the term 'claude' is not recognized as the name of a cmdlet. It is one problem with four wordings, and none of them come from Claude Code.

claude: command not found
Printed by your shell, not the CLI.

Diagnosis

What it actually is

The install directory is not on your PATH

The native installer (curl -fsSL https://claude.ai/install.sh | bash, or irm https://claude.ai/install.ps1 | iex on Windows) puts a launcher at ~/.local/bin/claude, a symlink into ~/.local/share/claude/versions/. On Windows it is %USERPROFILE%\.local\bin\claude.exe. The installer warns Native installation exists but ~/.local/bin is not in your PATH and prints the fix, but it does not edit your PATH itself, so plenty of default profiles never add that folder.

The terminal is older than the PATH change

A shell reads its PATH once, when it starts. A window that was already open keeps the old value, and a terminal inside VS Code or another editor inherits the PATH the editor started with. Fixing your profile and typing claude in the same old window fails exactly the way it did before.

The PATH line went into a file your shell never reads

zsh, the macOS default, reads ~/.zshrc. bash on Linux reads ~/.bashrc. Terminal on macOS starts bash as a login shell, which reads ~/.bash_profile and ignores ~/.bashrc. A correct line in the wrong file does nothing. Run echo $0 to see which shell you are actually in.

An npm install put it in the npm global bin

With npm install -g @anthropic-ai/claude-code the command lands in npm's global bin, which is $(npm prefix -g)/bin on macOS and Linux and the prefix folder itself on Windows, where it is a claude.cmd shim. If that folder is not on PATH, the package installed and the command is still missing.

nvm switched Node versions under you

Under nvm every Node version has its own global packages. Install claude with npm while one version is active, run nvm use to another, and the command disappears with the old version's bin directory. The native install avoids this: Anthropic's setup docs say the installed binary does not invoke Node at all.

The shell still remembers the old location

After moving from npm to the native installer, or uninstalling one copy, bash keeps a cache of where it last found each command. It then tries the old path and fails with No such file or directory naming a file that is gone, even though a working claude is on PATH. hash -r in bash or rehash in zsh clears it.

Installed in one environment, run in another

On Windows, PowerShell, CMD, Git Bash and WSL are not one environment. PowerShell, CMD and Git Bash share the Windows user PATH, but Git Bash only reads it when the window opens. WSL is a separate Linux system with its own home directory, so a Windows install is invisible there and it needs its own install from inside WSL.

A service has a different PATH than your terminal

Anything started by systemd, launchd or a Windows service inherits a minimal environment and never reads .bashrc or .zshrc. The same machine then runs the CLI by hand and fails to spawn it from the service, which reads as an install problem and is not one.

Check

Confirm it before you fix it

Run thisWhat a good answer looks like
command -v claudePrints an absolute path when the shell can find it and nothing at all when it cannot. Run it in the shell that failed rather than in a fresh one, because a new shell may have picked up a profile change the old one predates.
type -a claudeLists every claude on your PATH, in the order the shell tries them. One line is healthy. Two lines, for example ~/.local/bin/claude and an npm copy, means two installs, and the first one listed is the one that runs.
echo $PATH | tr ':' '\n' | grep -Fx "$HOME/.local/bin"Prints the folder if it is on PATH and nothing if it is not. Nothing here plus a file at ~/.local/bin/claude is the classic case, and the fix is one line in your shell profile.
ls -l ~/.local/bin/claudeWhether the native launcher exists at all. A symlink pointing into ~/.local/share/claude/versions/ is normal. No such file means the native installer never ran as this user.
npm prefix -gWhere npm puts global packages. Add /bin on macOS and Linux to get the folder that must be on PATH for an npm install of claude. Under nvm the answer changes with every nvm use.
claude doctorOnce claude runs at all, this prints Running: native or the npm equivalent, the path it is running from, and Config install method. Running and configured disagreeing is the leftover-install case.

Every command here has been run on a real machine. Termdeck answers the same questions for every machine you have connected, without opening a terminal on any of them.

Fix

Cheapest thing first

1. Add ~/.local/bin to PATH in zsh or bash

zsh: echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc then source ~/.zshrc. bash on Linux: the same line into ~/.bashrc. bash on macOS: into ~/.bash_profile, or into an existing ~/.bash_login or ~/.profile if you have one and no ~/.bash_profile. fish: fish_add_path ~/.local/bin. Then confirm with claude --version.

2. Add it to the Windows user PATH

PowerShell: $currentPath = [Environment]::GetEnvironmentVariable('PATH', 'User') then [Environment]::SetEnvironmentVariable('PATH', "$currentPath;$env:USERPROFILE\.local\bin", 'User'). CMD has no one-liner in the official docs: open System Properties, Environment Variables, edit the User PATH, and add %USERPROFILE%\.local\bin. Close every terminal afterwards, including Git Bash, because each one keeps the PATH it opened with.

3. Install inside WSL if that is where you work

Run curl -fsSL https://claude.ai/install.sh | bash in the WSL shell, then add ~/.local/bin to the WSL profile as above. A Windows install does not carry over.

4. Clear the shell cache or open a new window

hash -r in bash, rehash in zsh. A brand new terminal window does the same and also picks up any profile edit.

5. Keep one install and remove the rest

Anthropic recommends the native install. Remove an npm copy with npm uninstall -g @anthropic-ai/claude-code and the old local npm install with rm -rf ~/.claude/local. If claude doctor shows the running install and the configured one disagree, claude install repairs it. Then hash -r so the shell forgets the removed path.

6. Put the npm bin on PATH if you stay on npm

Add export PATH="$(npm prefix -g)/bin:$PATH" to your profile. Under nvm, either reinstall claude for each Node version you use or move to the native installer, which does not depend on Node.

7. Name the binary for anything that runs as a service

Where a service does the spawning, an absolute path removes the question entirely. The Termdeck agent takes TERMDECK_CLAUDE_EXE in ~/.termdeck/agent.env for this, and otherwise resolves in the order override, ~/.local/bin, then PATH. A service picks up a change only when it restarts. In Termdeck, press Recheck on the machine in Machines and accounts and it shows Claude Code as installed without a restart; see Engines.

Not this

What will not help

Reinstalling the CLI

A second install puts the binary in the directory it is already in. If the first one worked, nothing about the PATH that could not find it has changed.

Running it with sudo

Root has a different PATH again, usually a shorter one. Anthropic's setup docs say not to use sudo npm install -g at all: it turns a missing binary into one owned by the wrong user, and any files it creates are then owned by root.

Waiting for claude migrate-installer

Older guides tell you to run it. Claude Code 2.1.309 has no such subcommand, and claude migrate-installer simply starts the CLI. The current tools are the native installer, claude install and claude doctor.

FAQ

The shell answers command not found when you run claude, answered

Why does it say claude command not found right after installing?

The installer put claude in ~/.local/bin, or in the npm global bin, and that folder is not on your PATH yet, or your terminal was opened before the PATH changed. Check with command -v claude in a new window before reinstalling.

Where does the Claude Code installer put the binary?

The native installer uses ~/.local/bin/claude on macOS and Linux, a symlink into ~/.local/share/claude/versions, and %USERPROFILE%\.local\bin\claude.exe on Windows. An npm install puts it in the npm global bin, shown by npm prefix -g.

How do I fix zsh: command not found: claude on a Mac?

Add the line export PATH="$HOME/.local/bin:$PATH" to the end of ~/.zshrc, run source ~/.zshrc, and check with claude --version. If you use bash on macOS, the line goes in ~/.bash_profile instead.

How do I fix claude is not recognized as an internal or external command?

That is CMD or PowerShell failing to find claude.exe. Add %USERPROFILE%\.local\bin to your Windows user PATH, then close and reopen every terminal window. If claude came from npm, the npm prefix folder that holds claude.cmd must be on PATH instead.

Why does claude work in PowerShell but not in Git Bash or WSL?

Git Bash reads the Windows PATH only when it opens, so an old window misses the change. WSL is a separate Linux system with its own home and PATH, so it needs its own install from inside WSL.

Does claude migrate-installer still exist?

Not in Claude Code 2.1.309. To move from npm to the native install, run the native installer, uninstall the npm package, and use claude install if claude doctor reports a mismatch.

Does Claude Code need Node.js or nvm?

The native install does not. The npm package needs Node 22 or later to install, and under nvm it only exists for the Node version that was active when you installed it.

Why does claude work in my terminal but not from a service?

A service starts with a minimal environment and does not read your shell profile, so the directory your terminal adds is missing. Give the service an absolute path to the binary, or add the folder to the service environment, and restart it.