[BUG] npm-distributed plugins fail to resolve dependencies — cache directory lacks node_modules
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?
When installing an npm-distributed plugin via a marketplace, the plugin is copied to ~/.claude/plugins/cache/<marketplace>/<plugin>/<version>/ but without node_modules. Dependencies remain isolated in ~/.claude/plugins/npm-cache/node_modules/.
When the plugin executes from the cache directory, Node.js cannot resolve bare module imports (e.g., import { cli } from "clibuilder") because there's no node_modules in the resolution path.
Cache structure:
~/.claude/plugins/
├── npm-cache/
│ └── node_modules/
│ └── clibuilder/ # ✓ dependency installed here
└── cache/
└── cyberplace/
└── buddy-agent-harness/
└── 0.6.0/
├── dist/cli.mjs # imports "clibuilder"
└── (no node_modules) # ✗ can't resolve
What Should Happen?
Plugin dependencies should be resolvable at runtime. Possible fixes:
- Run plugins directly from
npm-cache/node_modules/<package>/instead of copying to cache - Set
NODE_PATHto includenpm-cache/node_modules/when executing plugins - Symlink or copy
node_modulesto the cache directory
Error Messages/Logs
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'clibuilder' imported from ~/.claude/plugins/cache/cyberplace/buddy-agent-harness/0.6.0/dist/cli.mjs
Steps to Reproduce
- Create/use a marketplace with an npm-distributed plugin that has runtime dependencies:
``json``
{
"name": "buddy-agent-harness",
"source": { "source": "npm", "package": "buddy-agent-harness" }
}
- Install the plugin:
/plugin install buddy-agent-harness@<marketplace> - Run any skill or command from the plugin
- Error:
Cannot find package 'clibuilder'
Note: The plugin buddy-agent-harness version 0.6.0 is published on npm and depends on clibuilder as a runtime dependency.
Claude Model
Opus
Is this a regression?
I don't know
Claude Code Version
2.1.234 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
The npm-cache correctly installs the plugin and its dependencies:
~/.claude/plugins/npm-cache/package.json:
{
"dependencies": {
"buddy-agent-harness": "^0.6.0",
...
}
}
But when copied to the plugin cache for execution, the node_modules are not included or linked.