medusajs/medusa · warning

Layout file has no default export, skipping.

Error message

Layout file has no default export, skipping.

What it means

The layouts generator scans src/admin/layouts/*.ts and expects each layout file to have a default export (the React component) plus a named `config` export. If the file has no default export, the plugin cannot register the layout and skips the file with this warning.

Source

Thrown at packages/admin/admin-vite-plugin/src/layouts/generate-layouts.ts:79

      file,
      error: e,
    })
    return null
  }

  let fileHasDefaultExport = false
  try {
    fileHasDefaultExport = await hasDefaultExport(ast)
  } catch (e) {
    logger.error(`An error occurred while checking for a default export.`, {
      file,
      error: e,
    })
    return null
  }

  if (!fileHasDefaultExport) {
    logger.warn(`Layout file has no default export, skipping.`, { file })
    return null
  }

  if (!hasConfigExport(ast)) {
    logger.warn(
      `Layout file has no 'config' named export. Export 'export const config = defineLayoutConfig(...)'.`,
      { file }
    )
    return null
  }

  const componentName = `LayoutComponent${index}`
  const configName = `LayoutConfig${index}`

  return {
    import: generateImport(file, componentName, configName),
    componentName,
    configName,

View on GitHub (pinned to 5e06e544a2)

Solutions

  1. Add a default export to the layout file: `export default function MyLayout() { ... }`
  2. Move non-layout helper files out of src/admin/layouts
  3. Restart the dev server to rescan layouts

Example fix

// before
export function MyLayout() { return <div>...</div> }

// after
export default function MyLayout() { return <div>...</div> }
Defensive patterns

Strategy: validation

Validate before calling

// quick check in a prebuild script
import { parse } from "@babel/core"
// or simply grep: files in src/admin/layouts must contain `export default`

Prevention

When it happens

Trigger: A .ts/.tsx file in src/admin/layouts that only exports named components, has no `export default function ...`, or exports everything via named exports.

Common situations: Helper/util files accidentally placed in the layouts directory; refactoring removed the default export; typo in export syntax.

Related errors


AI-assisted analysis of medusajs/medusa@5e06e544a2 (2026-08-27). Data as JSON: /api/errors/1ec457bca7946a19. Report an issue: GitHub.