[BUG] Incorrect Installation Diagnostics for npm-global Installation
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Claude Code 2.0.1 shows incorrect installation diagnostic warnings when installed via npm install -g, claiming it's a "native" installation and reporting configuration mismatches, even though the installation is functioning correctly.
Environment
Claude Code Version: 2.0.1
Installation Method: npm global (npm install -g @anthropic-ai/claude-code)
OS: macOS
Node Version: v22.19.0
npm Version: 11.6.1
Installation Details
bash
$ which claude
/usr/local/bin/claude
$ ls -la /usr/local/bin/claude
lrwxr-xr-x 1 user wheel 52 [date] /usr/local/bin/claude -> ../lib/node_modules/@anthropic-ai/claude-code/cli.js
$ npm list -g --depth=0 | grep claude
├── @anthropic-ai/claude-code@2.0.1
What Should Happen?
When installed via npm install -g, Claude Code should:
Correctly detect the installation method as npm-global
Not show warnings about native installation paths
Not report configuration mismatches between detected and actual installation method
Error Messages/Logs
**System Diagnostics**
⚠ installMethod is native, but claude command not found at /Users/[username]/.local/bin/claude
⚠ Insufficient permissions for auto-updates
⚠ No write permissions for auto-updates (requires sudo)
⚠ Installation config mismatch: running npm-global but config says native
Steps to Reproduce
- Install Claude Code globally:
npm install -g @anthropic-ai/claude-code - Verify installation:
which claude(should show/usr/local/bin/claude) - Create config file at
~/.claude/config.jsonwith:
json {
"installMethod": "npm-global"
}
- Run
claudein any project directory - Observe the system diagnostics warnings
Claude Model
None
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.0.1 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
Investigation Results
Looking at the compiled CLI code, the b$() function correctly detects npm-global based on the binary path:
javascriptif(["/usr/local/lib/node_modules", ...].some((Z)=>A.includes(Z)))
return"npm-global";
However, the diagnostics code appears to be checking for a native installation configuration somewhere else, possibly in a cached state or different config location.
Additional Context
- The warnings persist even after:
- Creating/updating
~/.claude/config.json - Killing all Claude processes with
pkill -f claude - Clearing cache with
rm -rf ~/.claude/.cache
- The actual functionality of Claude Code works correctly despite these warnings
- Config files checked:
~/.claude/config.json✓ (set tonpm-global)~/.claude/settings.json✓ (contains onlyalwaysThinkingEnabled)~/.claude/plugins/config.json✓ (contains onlyrepositories)
Workaround
Setting DISABLE_INSTALLATION_CHECKS=1 environment variable suppresses the warnings.
Suggested Fix
The diagnostics logic should respect the runtime-detected installation method (npm-global) and not compare it against a potentially stale or incorrectly initialized "native" configuration value. The detection logic in b$() appears correct, but the diagnostics validation logic may need to be updated to use the same detection method.
13 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
same issue
Have you previously installed the native executable?
Check
~/.claude.jsonor~/.claude/.config.json(the path you listed~/.claude/config.jsonis incorrect) for installMethod.Sorry yes you're right about the config path, below are the outputs from the suggested commands:
~/.claude.json:
~/.claude/.config.json: Does not exist (confirmed with
cat- file not found)Other config files in ~/.claude/:
Check for native installation:
No native installation foundI must have previously installed the native executable but have since removed it (worryingly don't remember doing this). The
~/.claude.jsonfile still contains"installMethod": "native"from that previous installation.Even though:
~/.local/bin/claudenpm-globalinstallation at/usr/local/bin/claudenpm-global...the diagnostics are reading the stale
installMethodvalue from~/.claude.jsonand showing warnings based on that outdated configuration.Should I have to, as I have done now, manually update
~/.claude.jsonto set"installMethod": "npm-global"? Or should there be / is there a command that should have handled this cleanup when I switched installation methods?This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
The problem is still present , and just because the issue has been inacvite for x amount of days, it doesn't really help in solving the problem by sending a message via a bot, that no one actually reads.
打开 /Users/<username>/.claude.json 文件,删除 "installMethod": native, 然后保存文件
之后就不会再出现这个警告:
installMethod is native, but claude command not found at /Users/<username>/.local/bin/claude但是我不知道这个方法会造成什么其他的意外情况,请谨慎选择。
Got the same problem
and now the automatic update is gone for some unknown reason
Still happening and automatic updates no longer work, possibly because of this issue.
I am using fnm to manage Node.js on my machine. This is my
npm config get prefix:Maybe this is the problem? What Node.js version manager are you using @mmc41 @madanyang @Philsmith1
@PaulRBerg
``` shell
npm list -g
@anthropic-ai/claude-code@2.1.12
Same issue on Linux (CachyOS / Arch-based)
I'm experiencing the same npm prefix mismatch on Linux. Originally reported in #31772, closing it in favor of this issue.
Setup
| | |
|---|---|
| Claude Code | 2.1.70 |
| Node.js | v25.7.0 |
| npm | 11.11.0 |
| OS | CachyOS Linux (Arch-based) |
| Kernel | 6.19.6-2-cachyos |
Root Cause (same as described here)
Claude Code is installed user-locally under
~/.local/, butnpm config get prefixreturns/usr. The auto-updater callsnpm i -g @anthropic-ai/claude-codewhich targets the wrong prefix — either failing due to missing permissions or updating a different (system-level) location.Workaround
Suggestion
The auto-updater should resolve the actual installation path (e.g. by following the symlink of
which claude) and use that prefix instead of relying onnpm config get prefix.fix npm config by creating a ~/,npmrc with
when using npm i -g everything will be installed to ~/.local/bin