The Problem
When setting up Playwright MCP server in Claude Desktop on macOS with Bun, you might encounter these errors:
|
|
This happens because Playwright requires Node.js APIs that aren’t available in Bun’s runtime environment.
Root Cause
The issue occurs when:
- Using
bunx
to run Node.js-based MCP servers like Playwright - npx finds the wrong Node.js version in PATH (e.g., v14 instead of v22)
- Modern npm/Node.js features conflict with older Node.js versions
Solution
Instead of using bunx
, configure Claude to use Node.js directly with explicit PATH control:
Step 1: Update Claude MCP Configuration
Edit your claude_desktop_config.json
:
|
|
Step 2: Key Changes Explained
- Direct Node.js path: Use full path to Node.js v22 npx
- Explicit PATH: Ensure Node.js v22 comes first in PATH environment
- Remove bunx: Don’t use Bun for Node.js-specific packages
Step 3: Verify Node.js Version
Check your Node.js installation:
|
|
Why This Works
- Compatibility: Node.js packages run in their native environment
- PATH priority: Node.js v22 takes precedence over older versions
- Environment isolation: Each MCP server gets its own environment
Alternative: Use Extensions
For simpler setup, consider using Claude Desktop extensions instead of manual MCP configuration. Extensions handle Node.js version management automatically.
Conclusion
When mixing Bun and Node.js in Claude MCP servers, use the right tool for each job. Keep Bun for Bun-compatible packages and use Node.js directly for Node.js-specific packages like Playwright.
This approach ensures reliable MCP server functionality without runtime conflicts.