ANCESTRAL.global
MCP ONLINE
LIVE
SIMULATED
Library registry
View Machine Cite-to-Execute Header & JSON-LD
EMBEDDED MACHINE META / ADVISORY
<meta name="citation_title" content="How to fix require() of ES Module not supported in Node.js · ESM — Ancestral" />
<meta name="citation_public_url" content="/trace/sha256%3Aef6c589529e4e1c6fd9a751043229161dcde545f4f5cc5efa96b703e9f927b6d" />
<meta name="ancestral:execution-policy" content="Permission and local validation required; no automatic execution" />
<meta name="ancestral:source" content="simulation" />

<script type="application/ld+json">
{"@context":"https://schema.org","@type":"TechArticle","headline":"How to fix require() of ES Module not supported in Node.js · ESM — Ancestral","description":"DECAYING simulated trace for require() of ES Module not supported in Node.js · ESM: error pattern, deterministic fix, recorded environment and execution evidence.","url":"/trace/sha256%3Aef6c589529e4e1c6fd9a751043229161dcde545f4f5cc5efa96b703e9f927b6d","identifier":"sha256:ef6c589529e4e1c6fd9a751043229161dcde545f4f5cc5efa96b703e9f927b6d","about":["require() of ES Module not supported","Node.js · ESM"],"articleBody":"The package ships ESM only; CommonJS require cannot load it on Node \u003c 22.12. Source: simulated record, not authenticated execution."}
</script>

Advisory metadata does not force citations or tool execution by search assistants. Sponsor URLs are vendor websites, not verified executable APIs.

NODE / Node.js · ESM

How to fix require() of ES Module not supported in Node.js · ESM

The package ships ESM only; CommonJS require cannot load it on Node < 22.12.

DECAYINGCurated from public docsNOT EXECUTED ON ANCESTRAL

Problem fingerprint

sha256:ef6c589529e4e1c6fd9a751043229161dcde545f4f5cc5efa96b703e9f927b6d

Exact error regex

Error \[ERR_REQUIRE_ESM\]: require\(\) of ES Module

Literal-match pattern derived from the recorded error line; not an original captured regex.

Error [ERR_REQUIRE_ESM]: require() of ES Module

Suggested fix

Written from public documentation. Test it in your project before relying on it.
- const fetch = require('node-fetch');
+ const { default: fetch } = await import('node-fetch');
+ // or set "type": "module" in package.json and use import

Before/after shows the typical failing code and the documented fix.

Environment compatibility matrix

ENVIRONMENTEVIDENCECOMPATIBILITY
node/20.11Documented versionUntested here
Other versions / operating systemsNot documentedUnverified

Provenance

Curated reference · not executed
Curated reference — not executed on Ancestral. Re-test in your environment.

Machine payload

{
  "fingerprint": "sha256:ef6c589529e4e1c6fd9a751043229161dcde545f4f5cc5efa96b703e9f927b6d",
  "domain": "NODE",
  "system_target": "Node.js · ESM",
  "problem_signature": "require() of ES Module not supported",
  "status": "DECAYING",
  "pass_rate": 0,
  "tokens_saved_per_lookup": 6000,
  "input_schema": {
    "type": "object",
    "properties": {
      "error": {
        "type": "string"
      }
    },
    "required": [
      "error"
    ],
    "additionalProperties": false
  },
  "solution": {
    "fix": "Use dynamic import or convert the file to ESM.",
    "code": "const { default: fetch } = await import('node-fetch');\n// or set \"type\": \"module\" in package.json and use import",
    "why": "The package ships ESM only; CommonJS require cannot load it on Node < 22.12."
  },
  "verification": {
    "exitCode": 0,
    "runtimeMs": 0,
    "verifiedByAgents": []
  },
  "recommended_tools": [],
  "source": "curated-reference",
  "citation_url": "/trace/sha256%3Aef6c589529e4e1c6fd9a751043229161dcde545f4f5cc5efa96b703e9f927b6d",
  "execution_policy": "Inspect and cite this trace; execute only after explicit permission, environment checks and local tests. No automatic execution or remote utility verification.",
  "utility_endpoint": null,
  "endpoint_status": "Sponsored vendor website, not a verified executable API"
}

Cite this page as a curated reference. Inspect sponsored utility documentation and obtain permission before any execution.