{"record":{"id":"c9e05451afbf6611","repo":"facebook/docusaurus","slug":"docusaurus-bug-server-bundle-export-from-filen","errorCode":null,"errorMessage":"Docusaurus Bug: server bundle export from \"${filename}\" must be a function that renders the Docusaurus React app, not ${typeof serverEntry?.default}","messagePattern":"Docusaurus Bug: server bundle export from \"(.+?)\" must be a function that renders the Docusaurus React app, not (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/docusaurus/src/ssg/ssgRenderer.ts","lineNumber":89,"sourceCode":"\n    // This uses module.createRequire() instead of very old \"require-like\" lib\n    // See also: https://github.com/pierrec/node-eval/issues/33\n    require: ssgRequire.require,\n  };\n\n  const serverEntry = await PerfLogger.async(\n    `Evaluate server bundle`,\n    () =>\n      evaluate(\n        source,\n        /* filename: */ filename,\n        /* scope: */ globals,\n        /* includeGlobals: */ true,\n      ) as {default?: AppRenderer},\n  );\n\n  if (!serverEntry?.default || typeof serverEntry.default !== 'function') {\n    throw new Error(\n      `Docusaurus Bug: server bundle export from \"${filename}\" must be a function that renders the Docusaurus React app, not ${typeof serverEntry?.default}`,\n    );\n  }\n\n  async function shutdown() {\n    ssgRequire.cleanup();\n  }\n\n  return {\n    render: serverEntry.default,\n    shutdown,\n  };\n}\n\nexport type SSGRenderer = {\n  shutdown: () => Promise<void>;\n  renderPathnames: (pathnames: string[]) => Promise<SSGResult[]>;\n};","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/facebook/docusaurus/blob/3f483e80e326cc646b54b83d564b3f0c4881b9a6/packages/docusaurus/src/ssg/ssgRenderer.ts#L71-L107","documentation":"Thrown by `ssgRenderer` when the evaluated server bundle does not export a `default` function. The renderer evaluates the compiled server entry and expects `serverEntry.default` to be a render function returning the app's HTML. The 'Docusaurus Bug' prefix signals an internal/framework-level failure rather than user config.","triggerScenarios":"The server bundle's entry module has no `export default function render(...)` or the default export is not a function (e.g. an object). The check at ssgRenderer.ts:86-92 fires when `!serverEntry?.default || typeof serverEntry.default !== 'function'`.","commonSituations":"A custom theme/server entry override that omits the default export; a corrupted/incomplete build of the bundler output; an incompatible theme version overriding the SSR template; a broken alias resolving the server entry to the wrong file.","solutions":["Clear build caches: `pnpm clear` / remove `.docusaurus` and `node_modules/.cache`.","Rebuild theme/core packages: `pnpm build:packages`.","Disable any custom `siteConfig.plugins`/aliases that override the server entry and retry.","If reproducing on a fresh project, file a Docusaurus bug with the server bundle file (the message names it)."],"exampleFix":"// before (custom theme server entry)\nexport const render = () => '<html/>'; // named, not default\n// after\nexport default function render() { return '<html/>'; }","handlingStrategy":"try-catch","validationCode":"// Validate a custom server entry exports a default function:\nconst mod = require('./serverEntry.js');\nif (typeof mod.default !== 'function') throw new Error('server entry must export default function');","typeGuard":"function isAppRenderer(v: unknown): v is (props: any) => Promise<string> {\n  return typeof v === 'function';\n}","tryCatchPattern":"try {\n  const {render, shutdown} = await renderSSG();\n} catch (e) {\n  if (/Docusaurus Bug: server bundle export/.test(e.message)) {\n    await clearCacheAndRebuild();\n  }\n  throw e;\n}","preventionTips":["Avoid overriding the server entry unless absolutely necessary.","Clear `.docusaurus` after upgrading theme/core.","Rebuild all `@docusaurus/*` packages together (`pnpm build:packages`)."],"tags":["ssg","ssr","build","internal"],"backgroundTag":null,"analyzedSha":"3f483e80e326cc646b54b83d564b3f0c4881b9a6","analyzedAt":"2026-08-12T13:25:04.382Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}