medusajs/medusa · warning

Layout file has no 'config' named export. Export 'export con

Error message

Layout file has no 'config' named export. Export 'export const config = defineLayoutConfig(...)'.

What it means

Each admin layout file must export a config object named `config` created with defineLayoutConfig, which supplies the label, icon, and other metadata used to generate the layout registration. If the file has a default export but no `config` named export, the plugin skips it with this warning.

Source

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

  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,
  }
}

/**
 * Checks whether the file exports a `config` defined via `defineLayoutConfig(...)`.

View on GitHub (pinned to 5e06e544a2)

Solutions

  1. Add `export const config = defineLayoutConfig({ label: "...", ... })` to the layout file
  2. Import defineLayoutConfig from @medusajs/admin-sdk
  3. Restart the dev server

Example fix

// before
export default function MyLayout() { ... }

// after
import { defineLayoutConfig } from "@medusajs/admin-sdk"

export const config = defineLayoutConfig({
  label: "My Layout",
})

export default function MyLayout() { ... }
Defensive patterns

Strategy: validation

Validate before calling

// assert in a prebuild script
const src = readFileSync(f, "utf8")
if (!/export\s+const\s+config\s*=/.test(src)) throw new Error(`${f} missing config export`)

Prevention

When it happens

Trigger: A layout component file in src/admin/layouts with a default export but missing `export const config = defineLayoutConfig({...})`.

Common situations: New layout created by copying a plain component; the config export was deleted; config exported under a different name (e.g. `layoutConfig`).

Related errors


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