[BUG] claude crashed in terminal, and i'm getting the error `zsh: command not found: claude` when i try to reopen by running `claude`
Resolved 💬 46 comments Opened Mar 13, 2025 by mag-e-williams Closed Aug 22, 2025
💡 Likely answer: A maintainer (bcherny, collaborator)
responded on this thread — see the highlighted reply below.
Environment
- Platform (select one):
- [ ] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other: <!-- specify -->
- Claude CLI version: <!-- output of
claude --version--> - Operating System: <!-- e.g. macOS 14.3, Windows 11, Ubuntu 22.04 -->
- Terminal: <!-- e.g. iTerm2, Terminal App -->
Bug Description
Claude was working well, and then all of the sudden it crashed, and now when i try to run claude in my terminal to reopen the interface, im getting zsh: command not found: claude
Expected Behavior
open the claude code interface
Actual Behavior
<!-- What actually happened -->zsh: command not found: claude
Additional Context
I;ve tried to uninstall and re-install the npm package, but im gettiing the following error when i try to uninstall
npm ERR! code EUNSUPPORTEDPROTOCOL
npm ERR! Unsupported URL Type "workspace:": workspace:^
npm ERR! A complete log of this run can be found in: /Users/maggiewilliams/.npm/_logs/2025-03-13T20_04_40_485Z-debug-0.log
maggiewilliams@Maggies-MacBook-Pro-5 clay-base % npm uninstall @anthropic-ai/claude-code
npm ERR! code EUNSUPPORTEDPROTOCOL
npm ERR! Unsupported URL Type "workspace:": workspace:^
46 Comments
Hey! Are you using the
-gflag?npm uninstall -g @anthropic-ai/claude-code && npm install -g @anthropic-ai/claude-codeWith that flag, im am still unable to successfully uninstall/reinstall and getting the following error:
and i am still unable to run claude, still getting the error
zsh: command not found: claudeafter previously being able to run it successfully
same thing happening for me
Solution, this has worked for me
Remove the existing directory before reinstalling:
Same here, i just closed Claude Code and after that in other directory I'm trying to execute "claude" and get "Command not found". macOS Sonoma
Same issue here
I didn't have an issue uninstalling, and reinstalling does not resolve the issue. I also used the
-gflag.I am having the same issue. Uninstall does not seem to work either
Having same issue
Also having this issue. Uninstalling and reinstalling is doing nothing to fix, which makes absolutely no sense, unless some funky stuff is going on during the install, which is being skipped during reinstall.
check my answer https://github.com/anthropics/claude-code/issues/471#issuecomment-2726301474
why would you close this? just cuz someone found a workaround using rm -rf doesn't mean this bug is fixed. This needs to be reopened
You might be using .bashrc (linux/wsl) when you are supposed to be using .zshrc (macos) - I had that issue. Try these steps :
┌[jonflatt☮DESKTOP-6M0SR6A]-(/mnt/c/Users/Jonathan/source/MCPControl)-[git://feature/coordinate-transformation ✗]-
└> claude
╭─────────────────────────────────────────────────╮
│ ✻ Welcome to Claude Code research preview! │
│ │
│ /help for help │
│ │
│ cwd: /mnt/c/Users/Jonathan/source/MCPControl │
╰─────────────────────────────────────────────────╯
✔ Loaded project memory • /memory
What's new:
• Resume conversations from where you left off
from with "claude --continue" and "claude
--resume"
• Claude now has access to a Todo list that helps
it stay on track and be more organized
╭────────────────────────────────────────────────╮
│ > exit │
╰────────────────────────────────────────────────╯
Auto-updating to v0.2.94…
Total cost: $0.0000
Total duration (API): 0s
Total duration (wall): 19.4s
Total code changes: 0 lines added, 0 lines removed
┌[jonflatt☮DESKTOP-6M0SR6A]-(/mnt/c/Users/Jonathan/source/MCPControl)-[git://feature/coordinate-transformation ✗]-
└> claude
zsh: command not found: claude
Breaks after auto-update, not sure why this was closed @bcherny
This worked for me.
This worked for me as well.
This worked for me as well
@nonmodernist Thank you. It worked for me as well....
This worked for me too
It is insane to me that this got closed. Clearly, this is multiple people's first experience with Claude Code. Anyway, for those who didn't have an NPM install from NVM and don't want to bother with adjusting the workaround with the correct path for the global NPM storage and stuff - just use Bun. It works and it works right away.
bun add -g @anthropic-ai/claude-codeThis happened to me too. I suspect the cause is that Claude Code was installing an update when it crashed and left itself in a corrupted state. This issue should absolutely be re-opened.
I'm having this issue too. Closed
claudecleanly and now:While using it, it was installing an update.
If you are using npm, the workaround should be
npm install -g @anthropic-ai/claude-codeWe will be shipping improvements here soon!
I used Claude desktop to fix mine, steps below.
Steps to Fix Claude Code
bashrm -rf ~/.npm-global/lib/node_modules/@anthropic-ai/claude-code
rm -rf ~/.npm-global/lib/node_modules/@anthropic-ai/.claude-code-*
bashnpm cache clean --force
bashwhich claude
npm list -g @anthropic-ai/claude-code
bashnpm install -g @anthropic-ai/claude-code
bashclaude --version
bashecho $PATH
ls -la ~/.npm-global/bin/
Alternative Solution (if above doesn't work):
If the above steps don't resolve it, try installing with a different prefix:
bash# Remove current npm prefix
npm config delete prefix
Install globally with default npm location
sudo npm install -g @anthropic-ai/claude-code
Or use npx without installing
npx @anthropic-ai/claude-code
Additional Troubleshooting:
Check for permission issues:
bashls -la ~/.npm-global/lib/node_modules/
Try running with full path:
bash~/.npm-global/bin/claude
Ensure your shell config is sourced:
bashsource ~/.zshrc
or if using bash
source ~/.bashrc
The main issue appears to be corrupted npm module directories. The force removal and clean reinstall should resolve it. Let me know which step works or if you encounter any other errors!
Installed yesterday, today having issue:
zsh: command not found: claudeIt didn't help.
This helped me. Thank you
Thanks, this worked for me too!
This shall work. If you look closer, it's trying to create a new hidden folder to point npm package installations to, as well as adding the bin folder which contains executables to the PATH. This is already a great indication pointing us to the right direction in case one don't want to do such a _manual_ creation and pointing.
Then the question boils down to "where is my npm packages bin folder?". I suppose the answer may depends on one's setup. For my case, I use asdf to manage my node versions. For some reasons it doesn't rebuild shims after installing global packages. One would have to do it manually (ref. here). So after rebuilding the shim with
asdf reshim nodejs,claudeworks instantaneously.I was using
nodenv(that I forgot about). Installed claude using the defaultnpm install -g @anthropic-ai/claude-codecommand, and claude couldn't be found. After finding this thread, remembered thatnodenvrecommends running:rehash- Rehash nodenv shims (run this after installing executables)Running
nodenv rehashfixed it instantly. Thank you, @williamchenghu.Experienced the same problem this week (macOS 15.5). So, FWIW, still not resolved. Like others, Claude was working perfectly, then I closed the terminal session, opened a new one, and:
../../.claude/local/node_modules/.bin/claude: No such file or directoryI do agree that this seems to be related to Anthropic's auto-updates that tries to run while you're actively using Claude in the terminal. None of the steps to resolve listed above worked for me, so YMMV.
For now, I've just resorted
npx @anthropic-ai/claude-code¯\_(ツ)_/¯Fresh install on OSX Sequoia is also showing command not found error. Not sure if using the asdf version manager is causing issues, but probably shouldn't.
npx it is
asdf reshim nodejsafternpm installfixedzsh: command not found: claudefor me if you are using asdf and zsh.Probably won't work for everyone, but I closed and reopened iTerm and it worked.
I had a similar issue on macOS. In my case, it was caused by a broken Node.js install (due to missing ICU libraries like libicui18n) and Homebrew not yet supporting macOS 15 properly.
Here’s what worked for me:
Step-by-step Fix:
npm uninstall -g @anthropic-ai/claude-codeIf you see a workspace: protocol error, it’s usually from a corrupted package-lock.json or monorepo. Clean up your global npm setup and reinstall using nvm.
npm install -g @anthropic-ai/claude-codeAfter that, the claude command worked again without issues.
If you're having trouble, try this:
unalias claudecurl -fsSL claude.ai/install.sh | bashclaude doctorMake sure you're running the native version.
You may need to restart your shell.
You may need to manually do
npm uninstall -g @anthropic-ai/claude-codeSame problem. Crashed and now it's
zsh: command not found: claude.Same problem, solved by reinstalling node
Download and install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
in lieu of restarting the shell
\. "$HOME/.nvm/nvm.sh"
Download and install Node.js:
nvm install 22
install claude
npm install -g @anthropic-ai/claude-code
Fix: Claude Code Error on macOS with Homebrew
Problem Description
After installing Claude Code via npm on macOS with Homebrew, users may encounter:
claude: command not foundafter installationclaudecommand throws:Root Cause
The npm installation creates a broken installation that:
Solution
Step 1: Check Current Installation
Step 2: Remove Broken npm Installation
Step 3: Install Using Native Installer
Step 4: Update PATH
Step 5: Verify Installation
Why This Works
~/.claude/local/Prevention
To avoid this issue in the future:
curl -fsSL https://claude.ai/install.sh | shAdditional Notes
References
---
Tested on: macOS with Homebrew, Node.js v24.5.0, npm installation of @anthropic-ai/claude-code
I was having issues with this on a local install and it turned out to be an incomplete install (I think the updater was breaking).
The solution, for me, was to remove the node modules folder and reinstall clean. (No history loss, this is just dependencies)
This one-liner should do it.
rm -rf ~/.claude/local/node_modules && (cd ~/.claude/local && npm install)Or use this one from the project folder to fix the issue and continue in Claude Code
rm -rf ~/.claude/local/node_modules && (cd ~/.claude/local && npm install) && claude -cI am using nvm, and an old project had the wrong version of node
nvm use 22solved my issue
The comments have the right solution:
rm -rfthe old Claude Code install, and re-install withnpm i -g @anthropic-ai/claude-code.We're actively working on moving away from NPM, because some of these install issues are inherent to NPM. Try the native binary (beta) to try this out today: https://docs.anthropic.com/en/docs/claude-code/setup#native-binary-installation-beta.
FWIW you don't need to remove the install, just the dependencies. I think the update is breaking somewhere and leaving things in a broken state. (Just a guess though.)
In my case,
installon the existing directory was throwing this error:this resolved it for me
To solve it temporarily, I used nvm to switch to another node version and reinstalled using
npm install -g @anthropic-ai/claude-codeThis issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.