claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] claude CLI Not Recognized After Global Installation on Windows

Open Shahzaibdev355 opened this issue 1 year ago • 16 comments

Environment

  • Platform (select one):

    • Anthropic API
  • Claude CLI version: 1.0.53 (Claude Code)

  • Operating System: Windows 11

  • Terminal: PowerShell

Bug Description

The documentation says that after installing the Claude CLI globally via: npm install -g @anthropic-ai/claude-code

I should be able to run the CLI using the Claude command from anywhere.

However, the command Claude is not recognized in my terminal, even though the package is globally installed and the global npm path is added to my environment PATH.

Steps to Reproduce

  1. Run npm install -g @anthropic-ai/claude-code
  2. Verify that the global npm path is added to the system PATH variable (in my case: C:\Users<username>\AppData\Roaming\npm)
  3. Open a new PowerShell terminal
  4. Run the claude command

Observe error:

claude : The term 'claude' is not recognized as the name of a cmdlet, function, script file, or operable program.

Expected Behavior

After installing globally, the claude command should be available as a global binary and executable from anywhere.

Actual Behavior

Running claude results in a “command not recognized” error, despite a successful global installation.

The only working alternative is this, if I run this, then Claude CLI works:

npx @anthropic-ai/claude-code

Additional Context

  • Other globally installed packages like firebase-tools and vercel work fine from the terminal.
  • This seems to be an issue either with the bin field in the package.json of the CLI, or a missing link/binary in the published package.

Execution Images:

Error when running claude:

Image Image

npx command works:

Image

Shahzaibdev355 avatar Jul 17 '25 13:07 Shahzaibdev355

Same issue for me on Mac - Sequoia 15.5 (24F74).

In the end I just added the following alias to my ~/.zshrc file (someone could do the same for their .bashrc file, etc)

alias claude="npx claude"

joekrump avatar Jul 18 '25 14:07 joekrump

Same issue here, also Windows 11 and PowerShell (Core, pwsh). I've also tried installing Claude Code to my home folder ((cd ~) && (npm install @anthropic-ai/claude-code)), same results.

leependu avatar Jul 20 '25 23:07 leependu

I also encountered this problem, I asked AI and tried the methods it provided to solve it. I set the global storage location for npm elsewhere, just add this path to the environment variables.

Image

liujianjie avatar Jul 23 '25 14:07 liujianjie

Sorry, I didn't see that you have added the npm global path to the environment variable. Excuse me, ignore my previous answer

liujianjie avatar Jul 23 '25 14:07 liujianjie

I found I just need to add %AppData%\npm to sytem env PATH, this fixed it for me on windows 11.

pascalandr avatar Jul 27 '25 13:07 pascalandr

ok @pascalandr will check it

Shahzaibdev355 avatar Jul 27 '25 20:07 Shahzaibdev355

Same Problem but with nvm. Does anyone have an idea about a possible solution?

prototowb avatar Jul 30 '25 18:07 prototowb

@prototowb have you tried my given solution?

Shahzaibdev355 avatar Jul 31 '25 23:07 Shahzaibdev355

I found the solution:

  1. npm uninstall -g claude (remove wrong package)
  2. npm install -g @anthropic-ai/claude-code (install correct one)
  3. claude setup-token`(get your token)
  4. [Environment]::SetEnvironmentVariable("CLAUDE_CODE_OAUTH_TOKEN", "your-token-here", "User") (set token) that's it:D

jaberjaber23 avatar Jul 31 '25 23:07 jaberjaber23

Thanks for sharing the solution. @jaberjaber23 , if this resolves the issue for others as well, kindly confirm so it can help validate the fix for the community.

Shahzaibdev355 avatar Aug 02 '25 12:08 Shahzaibdev355

Since I don't use token based usage of cluade this solved it for me

npm uninstall -g @anthropic-ai/claude-code irm https://claude.ai/install.ps1 | iex

jacobhallgren avatar Aug 04 '25 06:08 jacobhallgren

Since I don't use token based usage of cluade this solved it for me

npm uninstall -g @anthropic-ai/claude-code irm https://claude.ai/install.ps1 | iex

this solved it for me (Win11, PowerShell 7.5.2, NVM) - script serves a native install, currently in beta, check https://docs.anthropic.com/en/docs/claude-code/quickstart

BUT - this only fixed the issue for usage with Git Bash. In PowerShel the "Claude Code CLI not found in PATH" persists.

prototowb avatar Aug 07 '25 18:08 prototowb

the current fix is noted in the install text, you need to add

C:\Users\%USERPROFILE%\.local\bin

to your System Properties>Environment Variables>Path path and restart the terminal.

It's nice they put that note in the installation script output, but it took me a second to notice it, and I ended up on this thread first, so sharing for the others who also missed it on the output.

agstevens avatar Aug 09 '25 12:08 agstevens

@agstevens Thanks for pointing this out.

Shahzaibdev355 avatar Aug 11 '25 21:08 Shahzaibdev355

You'll want to where.exe claude to see if PATH is set up properly, and set the PATH as mentioned above if not.

ant-kurt avatar Aug 22 '25 20:08 ant-kurt

This 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.

github-actions[bot] avatar Aug 30 '25 14:08 github-actions[bot]