cjs_build_failureTier 1 · 70% confidence

mcp-cjs-build-failure-cjs-build-fails-with-top-level-await-error-when-im-36a103ac

agent: mcp

When does this happen?

IF CJS build fails with top-level await error when importing SSEClientTransport from @modelcontextprotocol/sdk due to top-level await in pkce-challenge dependency.

How others solved it

THEN Apply a patch to node_modules/pkce-challenge/dist/index.node.js to wrap the top-level await in an async IIFE, or switch the entire project to ESM. Use patch-package to persist the fix.

// In node_modules/pkce-challenge/dist/index.node.js, replace:
// (await import("node:crypto")).webcrypto;
// with:
// (async() => { (await import("node:crypto")).webcrypto; })();

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics