{"record":{"id":"8c7085f9da85831e","repo":"facebook/docusaurus","slug":"theme-themename-not-found","errorCode":null,"errorMessage":"Theme ${themeName} not found","messagePattern":"Theme (.+?) not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/docusaurus/src/commands/swizzle/themes.ts","lineNumber":30,"sourceCode":"import {askThemeName} from './prompts';\nimport {findStringIgnoringCase, type SwizzlePlugin} from './common';\n\nexport function pluginToThemeName(plugin: SwizzlePlugin): string | undefined {\n  if (plugin.instance.getThemePath) {\n    return (\n      (plugin.instance.version as {name?: string}).name ?? plugin.instance.name\n    );\n  }\n  return undefined;\n}\n\nexport function getPluginByThemeName(\n  plugins: SwizzlePlugin[],\n  themeName: string,\n): SwizzlePlugin {\n  const plugin = plugins.find((p) => pluginToThemeName(p) === themeName);\n  if (!plugin) {\n    throw new Error(`Theme ${themeName} not found`);\n  }\n  return plugin;\n}\n\nexport function getThemeNames(plugins: SwizzlePlugin[]): string[] {\n  const themeNames = _.uniq(\n    // The fact that getThemePath is attached to the plugin instance makes\n    // this code impossible to optimize. If this is a static method, we don't\n    // need to initialize all plugins just to filter which are themes\n    // Benchmark: loadContext-58ms; initPlugins-323ms\n    plugins.map((plugin) => pluginToThemeName(plugin)).filter(Boolean),\n  ) as string[];\n\n  // Opinionated ordering: user is most likely to swizzle:\n  // - the classic theme\n  // - official themes\n  // - official plugins\n  return _.orderBy(","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/facebook/docusaurus/blob/3f483e80e326cc646b54b83d564b3f0c4881b9a6/packages/docusaurus/src/commands/swizzle/themes.ts#L12-L48","documentation":"Thrown by `getPluginByThemeName(plugins, themeName)` when no loaded plugin's computed theme name matches the requested `themeName`. This is the lookup that powers every swizzle command — it must resolve a plugin before any component work begins.","triggerScenarios":"Calling `docusaurus swizzle <themeName> ...` (or the internal lookup) where `<themeName>` is not among the theme names produced by the currently loaded plugins. Causes: typo, theme not installed, theme plugin not registered in config.","commonSituations":"Typing `@docusaurus/classic-theme` instead of `@docusaurus/theme-classic`; forgetting to add the theme to `plugins`/presets in `docusaurus.config.js`; theme package installed but its `getThemePath` returns nothing; package not yet installed in node_modules.","solutions":["List available themes: `docusaurus swizzle --list` and copy the exact theme name.","Install the theme: `pnpm add <theme-package>` and add it to your config's `themes`/`presets`.","If it is a custom theme, ensure the plugin's `getThemePath()` returns a non-empty string so it is recognized as a theme.","Match the theme name exactly (case-sensitive, including the npm scope)."],"exampleFix":"// before (docusaurus.config.js)\nexport default { presets: [] }; // no theme registered\n// after\nexport default {\n  presets: [['classic', {}]],\n};","handlingStrategy":"validation","validationCode":"const themeNames = getThemeNames(plugins);\nif (!themeNames.includes(themeName)) {\n  throw new Error(`Unknown theme ${themeName}. Available: ${themeNames.join(', ')}`);\n}","typeGuard":"function isKnownTheme(name: string, names: string[]): name is string {\n  return names.includes(name);\n}","tryCatchPattern":"try { await getPluginByThemeName(plugins, themeName); }\ncatch (e) {\n  if (/Theme .* not found/.test(e.message)) {\n    console.error(`Run: docusaurus swizzle --list`); process.exit(1);\n  }\n  throw e;\n}","preventionTips":["Always run `docusaurus swizzle --list` first and copy the exact theme name.","Ensure the theme is installed and registered in `themes`/`presets`.","Pin theme versions to avoid silent removals."],"tags":["swizzle","theme","config","validation"],"backgroundTag":null,"analyzedSha":"3f483e80e326cc646b54b83d564b3f0c4881b9a6","analyzedAt":"2026-08-12T13:25:04.382Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}