Symptom
A CommonJS program that loads the SDK throws Error [ERR_REQUIRE_ESM] because require() of pkce-challenge is not supported in CommonJS. The issue says to use a dynamic import instead.
Evidence what you'll see
- The report traces it to
require()ofpkce-challengefrom the SDK, and names a CommonJS NestJS backend using@langchain/mcp-adapters. - A comment says the local patch was applied to
@modelcontextprotocol/sdk@1.7.0, indist/cjs/client/auth.js.
Why it happens
pkce-challenge is ESM-only. The SDK's CommonJS build loaded it with require(), which Node rejects.
Affected versions
@modelcontextprotocol/sdk 1.7.0 in the comment's patch. The linked issue does not name an operating system or a Node version.
Fix steps
0 of 1 done
Your check marks stay in this browser only.
How to check it worked
- Starting the CommonJS process no longer throws
ERR_REQUIRE_ESMforpkce-challenge.
If it still fails
- The linked issue does not describe
ERR_REQUIRE_ESMon 1.9.0. Another ESM-only package loaded withrequire()is a separate failure.
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