{
  "id": "nextjs/middleware-edge-runtime-node-api",
  "signature": "Error: The Edge Runtime does not support Node.js API 'X'. Use 'edge-runtime' compatible APIs.",
  "signature_zh": "错误：Edge 运行时不支持 Node.js API 'X'。请使用 'edge-runtime' 兼容的 API。",
  "regex": "The Edge Runtime does not support Node\\.js API",
  "domain": "nextjs",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Middleware in Next.js runs on the Edge Runtime, which has a limited set of APIs compared to Node.js. Using Node.js-specific modules like 'fs', 'path', or 'crypto' (without Web Crypto) throws this error.",
  "root_cause_type": "generic",
  "root_cause_zh": "Next.js 中间件在 Edge 运行时上运行，与 Node.js 相比 API 有限。使用 Node.js 特定模块如 'fs'、'path' 或 'crypto'（没有 Web Crypto）会抛出此错误。",
  "versions": [
    {
      "version": "next@13.4.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "next@14.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "next@15.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The Edge Runtime does not have a file system; any import of 'fs' will fail at runtime.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Dynamic imports also run on the Edge Runtime and are blocked; they don't fall back to Node.js.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Move Node.js-dependent logic out of middleware into a separate API route or server component.",
      "success_rate": 0.95,
      "how": "Move Node.js-dependent logic out of middleware into a separate API route or server component.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use Web APIs available in Edge Runtime, such as Web Crypto (crypto.subtle) instead of Node.js crypto.",
      "success_rate": 0.85,
      "how": "Use Web APIs available in Edge Runtime, such as Web Crypto (crypto.subtle) instead of Node.js crypto.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "将依赖 Node.js 的逻辑移出中间件，放入单独的 API 路由或服务器组件中。",
    "使用 Edge 运行时中可用的 Web API，例如 Web Crypto（crypto.subtle）替代 Node.js crypto。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://nextjs.org/docs/app/building-your-application/routing/middleware#runtime",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.95,
  "resolvable": "true",
  "first_seen": "2023-09-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}