Description
When installing @anthropic-ai/claude-code globally via npm on macOS
(with Node.js installed via Homebrew), the claude command is not
correctly added to the PATH. The installation creates an incorrect
symbolic link in the Homebrew binary directory, causing a "command not
found" error when trying to execute claude.
Environment
- OS: macOS
- Package Manager: Homebrew
- Node.js Version: v23.2.0
- npm Version: 11.4.2
Steps to Reproduce
- On a macOS system with Homebrew, install Node.js: brew install node.
- Install the Claude Code CLI globally: npm install -g
@anthropic-ai/claude-code.
- Attempt to run the claude command: claude --version.
Expected Behavior
The claude command should be accessible from the shell and should print
its version number.
Actual Behavior
The shell returns a "command not found" error.
Further investigation reveals that npm creates an incorrect symbolic
link:
- Location: /opt/homebrew/bin/claude
- Incorrect Target:
../lib/node_modules/@anthropic-ai/claude-code/cli.js
This link points to a JavaScript file instead of the executable
launcher script.
Workaround
The issue can be resolved by manually replacing the incorrect symbolic
link with the correct one.
- Remove the incorrect link:
1 rm /opt/homebrew/bin/claude
- Create the correct link to the executable in the Homebrew Cellar:
(Note: The Node.js version in the path may vary)
1 ln -s /opt/homebrew/Cellar/node/23.2.0/bin/claude
/opt/homebrew/bin/claude
After performing these steps, the claude command works as expected.
This suggests the issue lies in the package's installation script or
npm's handling of global binaries in a Homebrew environment.
Description
When installing @anthropic-ai/claude-code globally via npm on macOS
(with Node.js installed via Homebrew), the claude command is not
correctly added to the PATH. The installation creates an incorrect
symbolic link in the Homebrew binary directory, causing a "command not
found" error when trying to execute claude.
Environment
Steps to Reproduce
@anthropic-ai/claude-code.
Expected Behavior
The claude command should be accessible from the shell and should print
its version number.
Actual Behavior
The shell returns a "command not found" error.
Further investigation reveals that npm creates an incorrect symbolic
link:
../lib/node_modules/@anthropic-ai/claude-code/cli.js
This link points to a JavaScript file instead of the executable
launcher script.
Workaround
The issue can be resolved by manually replacing the incorrect symbolic
link with the correct one.
1 rm /opt/homebrew/bin/claude
(Note: The Node.js version in the path may vary)
1 ln -s /opt/homebrew/Cellar/node/23.2.0/bin/claude
/opt/homebrew/bin/claude
After performing these steps, the claude command works as expected.
This suggests the issue lies in the package's installation script or
npm's handling of global binaries in a Homebrew environment.