AgentFixboard

MCP TypeScript SDK fails in CommonJS projects with ERR_REQUIRE_ESM

Importing the MCP TypeScript SDK (directly or through an adapter) in a CommonJS project such as NestJS fails at runtime.

From GitHub

modelcontextprotocol/typescript-sdk

Difficulty
Easy
Time
~5 min
Steps
1
Fixed in
1.9.0
Last checked

Verified fix: PR #254 merged on . Fixed in 1.9.0 (first stable release containing the merge commit). Last checked .

Symptom

Importing the MCP TypeScript SDK (directly or through an adapter) in a CommonJS project such as NestJS fails at runtime.

Evidence what you'll see

  • Error [ERR_REQUIRE_ESM]: require() of ES Module pkce-challenge is not supported
  • Reported on @modelcontextprotocol/sdk 1.7.0

Cause

The SDK required pkce-challenge, which at the time shipped only as an ES module.

Fix steps

0 of 1 done

Your check marks stay in this browser only.

Verify the fix worked

  • Start the CommonJS app and confirm the SDK loads without ERR_REQUIRE_ESM.

Sources and credit

Summarized in our own words from these public reports. Credit goes to their authors.

Provided as is, without warranty. Try changes in a non-production environment and back up first. Security-related steps: verify against the official docs. Terms · Request removal or attribution change

Hit an error we don't cover? Submit it