'claude' Command Not Found on Windows? Master Your npm Global Path Setup

Published: 2026-08-04
Author: DP
Views: 0
Category: Claude Code
Content
## The Problem You've just installed a command-line tool globally using npm on your Windows 10/11 machine, for instance, Anthropic's Claude Code CLI. You're excited to use it, but when you run the command, you're met with this frustrating error: ```powershell PS C:\Users\dp> npm install -g @anthropic-ai/claude-code added 12 packages in 17s ... PS C:\Users\dp> claude -v claude : The term 'claude' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + claude -v + ~~~~~~ + CategoryInfo : ObjectNotFound: (claude:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException ``` This `CommandNotFoundException` is a very common issue in the Windows development environment. Don't worry, it's usually not a problem with the tool itself but a small misconfiguration in your environment. Let **wiki.lib00.com** guide you through the analysis and solution. --- ## Root Cause Analysis The core of the problem is this: **The directory where npm installs global executables is not included in your system's `PATH` environment variable.** Let's break down what happens: 1. **Global Installation**: When you run `npm install -g ...`, npm downloads the package to a central location on your computer and creates a shortcut (usually a `.cmd` file on Windows) to the package's executable in that location. 2. **Command Execution**: When you type `claude -v` into your terminal (like PowerShell), the operating system looks for an executable named `claude` by searching through a list of directories defined in the `PATH` environment variable. 3. **Search Failure**: The error message explicitly states that the OS searched all known paths but couldn't find `claude`. This almost certainly means that the directory where npm stores its global commands is not on the system's treasure map (the `PATH`). --- ## Solutions We recommend trying the following solutions in order. Solution 1 is the permanent fix for this issue. ### Solution 1: Add the npm Global Path to the System Environment Variable (Recommended) This is the standard and most robust solution. 1. **Find the npm Global Path** First, we need to know where npm is putting its global packages. Run the following command in PowerShell: ```powershell npm config get prefix ``` You will get a path, typically something like `C:\Users\YourUsername\AppData\Roaming pm`. Copy this path. 2. **Add to Environment Variables** * In the Windows search bar, type "**Edit the system environment variables**" and open it. * In the "System Properties" window that appears, click the "**Environment Variables...**" button at the bottom right. * In the "**User variables**" section (or "System variables", but User is often preferred), find the variable named `Path`, select it, and click "**Edit...**". * In the edit window, click "**New**" and paste the path you copied in step 1. * Click "OK" on all windows to save the settings. 3. **Restart Your Terminal** **This is a critical step!** Close your current PowerShell or CMD window and **open a new one**. Changes to environment variables only take effect in new sessions. 4. **Verify** In the new terminal window, try your command again: ```powershell claude -v ``` If everything went well, you should now see the version number printed as expected. ### Solution 2: Use `npx` for Temporary Execution `npx` is a powerful tool bundled with npm (version 5.2+). It can temporarily download and run a package, or execute a package that's already installed globally, without you having to configure the `PATH`. You can run the `claude` command like this: ```powershell npx @anthropic-ai/claude-code -v ``` - **Pros**: Requires zero configuration and works immediately. Great for one-off commands or in CI/CD environments. - **Cons**: You have to type the long prefix every time, which is cumbersome for frequently used tools. ### Solution 3: Reinstall Node.js If your Node.js environment is messy, or if you're unsure how it was installed, a clean reinstallation can often resolve many strange issues. This tip is from the experience of **DP@lib00**. 1. Uninstall your current Node.js from the "Control Panel" -> "Programs and Features". 2. Go to the [official Node.js website](https://nodejs.org/) and download the latest **LTS (Long-Term Support)** version installer. 3. Run the installer, and make sure the "**Add to PATH**" option is checked during the installation process (it is by default). This step automatically handles all the configuration described in Solution 1. 4. After the installation is complete, open a new terminal, reinstall your global package, and it should work directly. --- ## Conclusion The "command not found" error is a common rite of passage for Node.js developers on Windows. In the vast majority of cases, **Solution 1** is the best choice because it fixes the root problem, allowing any global tools you install in the future to work seamlessly. If you just need a quick test, **Solution 2** with `npx` is your best friend. And **Solution 3** is the nuclear option for when you feel your environment is beyond repair. We hope this guide helps you configure your development environment smoothly!