{"record":{"id":"d920f1d5d9788861","repo":"facebook/docusaurus","slug":"docusaurus-could-not-load-module-at-path-path-mo","errorCode":null,"errorMessage":"Docusaurus could not load module at path path=${modulePath}","messagePattern":"Docusaurus could not load module at path path=(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/docusaurus-utils/src/moduleUtils.ts","lineNumber":57,"sourceCode":"      default: options?.default,\n    });\n\n    if (DEBUG) {\n      console.log('Jiti module loaded', {\n        modulePath,\n        options,\n        type: typeof module,\n        keys:\n          module && typeof module === 'object'\n            ? Object.keys(module)\n            : undefined,\n        module,\n      });\n    }\n\n    return module;\n  } catch (error) {\n    throw new Error(\n      logger.interpolate`Docusaurus could not load module at path path=${modulePath}`,\n      {cause: error},\n    );\n  }\n}\n","sourceCodeStart":39,"sourceCodeEnd":63,"githubUrl":"https://github.com/facebook/docusaurus/blob/3f483e80e326cc646b54b83d564b3f0c4881b9a6/packages/docusaurus-utils/src/moduleUtils.ts#L39-L63","documentation":"Thrown by loadFreshModule() when jiti.import() rejects while trying to load a module. jiti is Docusaurus's loader for ESM, CJS, JSON, and TypeScript files (used so user config and plugin files can be authored in any of those formats). The underlying rejection — syntax error, missing file, missing dependency, bad export — is attached as {cause: error} so the real failure is preserved.","triggerScenarios":"Loading a docusaurus.config.ts / plugin file / theme component via loadFreshModule where the module has a TypeScript compile error, a missing import, a SyntaxError, exports something jiti cannot interop, or simply does not exist at the resolved path.","commonSituations":"A syntax error in docusaurus.config.ts or a plugin .ts file. Importing a dependency that is not installed (npm install was incomplete). An ESM/CJS interop mismatch where the module has no default export but options.default was set. A path alias that jiti does not resolve. Upgrading a dependency that changed its export shape.","solutions":["Read the cause property of the thrown error — it carries the original jiti/compile error with file and line.","Fix the reported syntax/import error in the offending module, then rebuild.","If the cause is a missing dependency, install it (pnpm install <dep>) and confirm it resolves.","If options.default was set but the module has no default export, either add a default export to the module or drop the options.default flag."],"exampleFix":"// before — plugin file uses an uninstalled import\nimport { foo } from 'not-installed-pkg';\nexport default function plugin() { /* ... */ }\n\n// after\n// pnpm add not-installed-pkg\nimport { foo } from 'not-installed-pkg';\nexport default function plugin() { /* ... */ }","handlingStrategy":"try-catch","validationCode":"import fs from 'fs-extra';\n\nasync function modulePathLooksValid(modulePath: string): Promise<boolean> {\n  // basic existence check for relative/absolute file paths; not exhaustive\n  return modulePath.startsWith('.') ? fs.pathExists(modulePath) : true;\n}","typeGuard":null,"tryCatchPattern":"try {\n  await loadFreshModule(modulePath, options);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith('Docusaurus could not load module')) {\n    // err.cause is the original jiti error: TS compile error, missing dep, etc.\n    console.error(err.cause);\n  }\n  throw err;\n}","preventionTips":["Ensure any module passed to loadFreshModule compiles and resolves its imports independently before wiring it into Docusaurus.","Keep dependencies installed (pnpm install) so missing-import failures cannot occur.","If options.default is set, make sure the module actually has a default export."],"tags":["module-loader","jiti","typescript","config","esm"],"backgroundTag":null,"analyzedSha":"3f483e80e326cc646b54b83d564b3f0c4881b9a6","analyzedAt":"2026-08-12T13:25:04.382Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}