Fixing Claude Code npm Install Errors

Key Takeaway

Claude Code npm install failing? Check the @ in the package name, your Node.js version and npm permissions, or skip npm and use the native installer.

Fixing Claude Code npm Install Errors

Claude Code npm install failing? Most errors come from four things: a missing @ in the package name, npm’s global folder permissions, blocked install steps, or a second copy of Claude Code. The quickest fix for most of them is Anthropic’s native installer, which doesn’t use npm at all.

Here’s how a bad install usually unfolds, one error at a time, and the fix for each.

What’s the right npm command?

This one, typed exactly:

npm install -g @anthropic-ai/claude-code

The npm package needs Node.js 22 or later. Anthropic also says never to put sudo in front of it.

Why does npm try to clone something from GitHub?

Because the @ is missing. Picture it. You search “npm install anthropic-ai/claude code”, copy the words into your terminal and press Enter.

Without the @ at the start, npm reads anthropic-ai/claude-code as a GitHub address, not a package name. It tries to clone a repository with Git instead of installing Claude Code. Put the @ back and run it again.

What does EACCES: permission denied mean?

Your user can’t write to the folder npm installs global packages into.

This is the moment you’re tempted to type sudo. Don’t. Anthropic warns that sudo npm install -g causes permission problems and security risks of its own.

The fix Anthropic gives is to switch installers. On Mac, Linux or WSL:

curl -fsSL https://claude.ai/install.sh | bash

On Windows PowerShell:

irm https://claude.ai/install.ps1 | iex

Is the EBADENGINE warning a problem?

No. It means your Node.js is older than 22. npm prints the warning and finishes the install anyway.

Claude Code still runs, because the package installs a native program that doesn’t use your Node.js once it’s in place. Update Node when you get a chance, but this warning isn’t what’s stopping you.

What does “claude native binary not installed” mean?

npm skipped part of the install. The real Claude Code program arrives as an optional extra package, and a setup step copies it into place.

Two settings break that:

CauseFix
Optional packages turned off (--omit=optional, or optional=false in .npmrc)Remove the setting and reinstall
Install scripts turned off (--ignore-scripts)Reinstall without the flag

If you use a company npm mirror, it has to carry the platform packages too. Ask whoever runs it.

Why does PowerShell say running scripts is disabled?

Windows is blocking the small launcher scripts npm creates. You’ll see npm.ps1 or claude.ps1 in the error.

The simplest fix is to stop using npm on Windows. The PowerShell installer above installs a real program, not a script, so the block doesn’t apply. You can also type npm.cmd or claude.cmd instead, which the block doesn’t cover.

What if npm says ENOTEMPTY?

An earlier install got interrupted and left a folder behind. npm can’t move it out of the way.

The npm error path line names the folder. Delete it, plus any folders next to it that start with .claude-code-, then install again.

Why does it still say “claude: command not found”?

Either the install folder isn’t on your PATH, or the terminal hasn’t caught up. Open a new terminal window first. Then run:

claude --version

A working install prints a version number. If it still fails, check for two copies.

How do you check for two installs?

Run which -a claude on Mac or Linux, or where.exe claude on Windows. More than one result means more than one install, and Anthropic says that causes version mismatches.

Keep the native one. Remove the npm copy with:

npm uninstall -g @anthropic-ai/claude-code

Don’t fight npm for an hour. If the first fix doesn’t work, use the native installer and move on. It also updates itself in the background, which an npm install can’t do when that same folder isn’t writable. More on that in How to Update Claude Code.

Frequently asked questions

Is npm install still supported for Claude Code? Yes. npm install -g @anthropic-ai/claude-code installs the same program as the native installer. Anthropic recommends the native installer, which updates itself in the background.

What Node.js version does Claude Code need? The npm package needs Node.js 22 or later. On older versions npm shows an EBADENGINE warning but still finishes the install.

Should I use sudo to install Claude Code with npm? No. Anthropic warns against sudo npm install -g. Switch to the native installer instead.

Do I need to pay before I install Claude Code? Installing costs nothing, but you need a paid plan or API credits to log in. Pro starts at $20 a month, and the free Claude plan doesn’t include Claude Code. See How Much Does Claude Code Cost?


Installed and ready? Start with What Is Claude Code?, or watch my free video, where I build a real site with it start to finish. Watch the free video.

Want Bryan to review your site?

Free local SEO audit: Bryan reviews your Google Business Profile, website, listings and map-pack competitors, and tells you what to fix first.

Get My Free Audit →