{
  "id": "nextjs/invalid-runtime-config-cjs",
  "signature": "Error: next.config.js must use CommonJS module syntax (module.exports = ...) or be a valid ESM export.",
  "signature_zh": "错误：next.config.js 必须使用 CommonJS 模块语法（module.exports = ...）或有效的 ESM 导出。",
  "regex": "next.config.js must use CommonJS module syntax",
  "domain": "nextjs",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "Next.js loads next.config.js with Node.js require(), which expects CommonJS exports. Using ES module syntax like export default or export const without proper configuration causes a parse error.",
  "root_cause_type": "generic",
  "root_cause_zh": "Next.js 使用 Node.js require() 加载 next.config.js，期望 CommonJS 导出。使用 ES 模块语法如 export default 或 export const 而没有正确配置会导致解析错误。",
  "versions": [
    {
      "version": "13.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "13.5.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "14.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "14.2.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "15.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Adding 'type': 'module' to package.json and using ESM syntax in next.config.js",
      "why_fails": "Next.js does not support ESM for next.config.js even if the package.json has type:module. It always expects CommonJS.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using export default function nextConfig() { ... } which is valid ESM but not CommonJS",
      "why_fails": "Node.js require() cannot interpret export default; it expects module.exports = ...",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Change next.config.js to use CommonJS syntax: /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true }; module.exports = nextConfig;",
      "success_rate": 0.95,
      "how": "Change next.config.js to use CommonJS syntax: /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true }; module.exports = nextConfig;",
      "condition": "",
      "sources": []
    },
    {
      "action": "If you prefer ESM, rename the file to next.config.mjs and use export default; Next.js 14+ supports .mjs extension for ESM configs.",
      "success_rate": 0.9,
      "how": "If you prefer ESM, rename the file to next.config.mjs and use export default; Next.js 14+ supports .mjs extension for ESM configs.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Change next.config.js to use CommonJS syntax: /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true }; module.exports = nextConfig;",
    "If you prefer ESM, rename the file to next.config.mjs and use export default; Next.js 14+ supports .mjs extension for ESM configs."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://nextjs.org/docs/app/api-reference/next-config-js#module-system",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.95,
  "resolvable": "true",
  "first_seen": "2022-12-01",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}