[SOLVED] How to Fix “claude command not found” Issue After Installing Claude Code [Mac Terminal Guide]

,
[SOLVED] How to Fix “claude command not found” Issue After Installing Claude Code [Mac Terminal Guide]

1Summary: What You’ll Learn in This Article

  • Why the Claude Code command doesn’t work in your terminal despite successful installation
  • How to handle missing .bashrc or .zshrc files on Mac
  • Step-by-step solution to properly set up your PATH and fix the issue immediately

This article is written for Mac environments (zsh) as of April 2025.
Reference: DigitalOcean and others

2Background: Installed Claude Code But It’s Not Working?

You recently installed Anthropic’s developer tool “Claude Code,” were excited to use it, but when you typed the claude command in your terminal, you got:

zsh: command not found: claude

Sounds familiar? Many developers encounter this frustrating experience.

The truth is, your installation was actually successful, but your terminal doesn’t recognize the command path!

If you’re interested in developing with Claude, check out What is Claude Code? The Ultimate AI Coding Assistant for Developers for a comprehensive guide on basic usage and advanced techniques!

What makes this trickier is that in Mac environments, the .bashrc or .zshrc files might not exist by default. In such cases, you need to add some configuration yourself.

3The Cause: PATH Not Set + Missing Configuration Files

Claude Code is installed via npm, so the executable files are typically placed in ~/.npm-global/bin or similar directories. However, if your terminal doesn’t recognize this directory, you won’t be able to use the command.

Additionally, the configuration files (.bashrc or .zshrc) that you need to edit to add the PATH might not exist in the first place.

4Solution: Step-by-Step Guide

Here’s the step-by-step solution that worked for me!

① Check for Hidden Files in Your Home Directory

First, run this in your terminal:

Terminal
ls -a ~

This will show if .bashrc or .zshrc exists. If not, move on to the next step!

② Create .zshrc (or .bashrc)

If the file doesn’t exist, create it yourself:

Terminal
touch ~/.zshrc

(If you prefer bash, use touch ~/.bashrc)

③ Edit the File and Add PATH

Next, open the file in a text editor:

Terminal
nano ~/.zshrc

Add the following line:

~/.zshrc
export PATH=$PATH:~/.npm-global/bin

🔥 Note

If you specified a different path when running npm install -g, adjust the above line accordingly.

After editing, save and exit with Ctrl + X → Y → Enter.

④ Apply the Settings Immediately

Creating the file isn’t enough. You need to apply the settings to your current terminal:

Terminal
source ~/.zshrc

That’s it!

⑤ Check if the claude Command Works

Try running:

Terminal
claude

If there’s no error, you’ve successfully fixed the issue! 🎉

5If It’s Still Not Working:

  • Use npm config get prefix to confirm your global installation directory
  • Check if the claude file actually exists in the path you configured
  • If all else fails, try restarting your terminal

6Conclusion: Set Up Your Environment First!

The root cause of the “claude command not found” issue boils down to “missing shell configuration file” + “PATH not set”.

Not just for Claude Code, but for any tools installed globally via npm, make it a habit to check your PATH settings first. This will save you a lot of headaches in the future.

💡 Pro Tip

If you plan to use Node.js tools frequently, consider installing nvm (Node Version Manager) for even easier management!

7Afterword: A Small Hurdle, A Valuable Lesson!

At first, I was confused: “It said installation was successful, so why can’t I use the command?” But after investigating, I realized my Mac terminal environment was more barebones than I expected.

If you’re using Windows and want to use Claude, check out How to install Claude Code on WSL (Windows Subsystem for Linux) for Windows-specific setup instructions!

This troubleshooting experience shows that any issue can be solved by calmly investigating the causes one by one. If you’re in the same situation, I hope this guide helps you resolve it smoothly!

Until next time! 🚀

If this information was helpful, please share it with others! More detailed npm troubleshooting articles are coming soon 📚!

Want to boost your productivity on Mac even further? Check out Must-see for Mac users! A collection of handy keyboard shortcuts that will boost your work efficiency for time-saving techniques including terminal operations!

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *