[Bug] Native image processor (sharp) not found in Windows bundle since v2.1.88 — breaks image paste in heavy-context sessions

Resolved 💬 2 comments Opened Apr 2, 2026 by MB-967 Closed May 27, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report
  • [x] I am using the latest version of Claude Code

Bug Description

Since Claude Code v2.1.88 (VS Code extension, Windows), pasting images fails with Native image processor module not available when the session has a heavy context (many MCP servers, large project files, structured commands).

The bug does not manifest in every session — only when the total context payload is large enough to trigger Claude Code's image resize pipeline. This likely explains why it hasn't been widely reported yet: users with minimal MCP servers and small projects won't hit the threshold that triggers the resize path. Users with multiple MCP servers (Notion, Canva, Mermaid Chart, Filesystem, Chrome, etc.) and heavy project context (structured commands loading checkpoints, rules, contracts, code files) hit it consistently.

Error

Error: Claude Code returned an error result: Unable to resize image — dimensions exceed 
the 2000x2000px limit and image processing failed. Please resize the image to reduce its 
pixel dimensions.; Error: Native image processor module not available
    at <anonymous> (B:/~BUN/root/src/entrypoints/cli.js:1297:24770)
    at _ (B:/~BUN/root/src/entrypoints/cli.js:1297:24844)
    at metadata (B:/~BUN/root/src/entrypoints/cli.js:1297:24968)
    at mI (B:/~BUN/root/src/entrypoints/cli.js:1337:2204)
    at processTicksAndRejections (native:7:39)

Reproduction

Consistent repro (100%)

  1. Have multiple MCP servers connected (Notion, Canva, Mermaid Chart, or similar)
  2. Open a project with CLAUDE.md, .claude/rules/, _context/ files (heavy context)
  3. Launch a structured command (e.g., /build or any custom command that loads checkpoint + rules + project files)
  4. Paste any image (even 973×552px — well under any limit)
  5. → Error: Native image processor module not available

Light-context behavior

  1. Open a fresh, simple chat (no command, no heavy context)
  2. Paste an image → works
  3. This confirms the image itself isn't the problem — the resize pipeline is only triggered when total context is large

Version bisect

  • v2.1.87: works correctly — images paste fine in all sessions including heavy-context
  • v2.1.88+: broken — sharp module not found when resize pipeline is triggered
  • v2.1.90 (current): still broken

Root cause analysis

The bundled cli.js (Bun bundle, virtual filesystem B:/~BUN/root/) calls require('sharp') to read image metadata and resize when the total API payload needs optimization. Since v2.1.88, sharp is no longer resolvable from within the Bun bundle on Windows.

Key evidence:

  • sharp is not included in the package's node_modules or vendor directory by default
  • The Bun virtual filesystem (B:/~BUN/root/) does not fall through to Node's native module resolution
  • Manually installing sharp (cd node_modules/@anthropic-ai/claude-code && npm install sharp) places it in the right directory, but the bundle's require() still can't find it without additional configuration

Workaround

Two-step fix that works:

Step 1: Install sharp in Claude Code's package directory

cd C:\nvm4w\nodejs\node_modules\@anthropic-ai\claude-code
npm install sharp

Step 2: Set NODE_PATH so Node.js resolves sharp before the bundle's resolver

[System.Environment]::SetEnvironmentVariable("NODE_PATH", "C:\nvm4w\nodejs\node_modules\@anthropic-ai\claude-code\node_modules", "User")

Then restart VS Code completely. NODE_PATH forces Node's module resolution to find sharp before the Bun bundle's virtual filesystem lookup fails.

Note: Step 1 alone is not sufficient — the Bun bundle's require() does not resolve from the local node_modules. Both steps are required.

Note: npm install -g sharp does not work either — the global sharp is not in the bundle's resolution path.

Why this bug may be under-reported

The resize pipeline is only triggered when the total context payload is large. Users with:

  • Few or no MCP servers
  • Small projects without structured commands
  • Simple chat sessions

...will never hit the resize threshold, and their images will always work. The bug specifically affects power users with heavy configurations — multiple MCP servers, structured project governance, large codebases with many context files.

Environment Info

  • Platform: Windows 11
  • Terminal: VS Code integrated terminal
  • Claude Code version: 2.1.90
  • VS Code extension: anthropic.claude-code-2.1.90-win32-x64
  • Node.js: v22.21.1 (via nvm4w)
  • Installation method: npm global (claude.cmd shim → node.exe → bundled cli.js)
  • MCP servers active: Notion, Canva, Mermaid Chart, Filesystem, Claude in Chrome

Expected behavior

Image paste should work regardless of context size. Either:

  1. Bundle sharp correctly for Windows, or
  2. Fall through to Node's native require() when the bundle's resolution fails, or
  3. Handle the missing sharp gracefully (skip resize, send image as-is, warn user) instead of crashing the entire session

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗