tailwindlabs/tailwindcss · error · Error

`@config` cannot have a body.

Error message

`@config` cannot have a body.

What it means

Thrown when an `@config` at-rule has any child nodes (`node.nodes.length > 0`). `@config` only takes a path argument; it cannot have a body. The check runs before the nesting check.

Source

Thrown at packages/tailwindcss/src/compat/apply-compat-hooks.ts:129

      pluginPaths.push([
        {
          id: pluginPath,
          base: ctx.context.base as string,
          reference: !!ctx.context.reference,
          src: node.src,
        },
        Object.keys(options).length > 0 ? options : null,
      ])

      features |= Features.JsPluginCompat
      return WalkAction.Replace([])
    }

    // Collect paths from `@config` at-rules
    if (node.name === '@config') {
      if (node.nodes.length > 0) {
        throw new Error('`@config` cannot have a body.')
      }

      if (ctx.parent !== null) {
        throw new Error('`@config` cannot be nested.')
      }

      configPaths.push({
        id: node.params.slice(1, -1),
        base: ctx.context.base as string,
        reference: !!ctx.context.reference,
        src: node.src,
      })
      features |= Features.JsPluginCompat
      return WalkAction.Replace([])
    }
  })

  registerLegacyUtilities(designSystem)

View on GitHub (pinned to 16e94cbf7f)

Solutions

  1. Remove the block: `@config "./tw.js";` with no braces.
  2. If you intended to pass plugin options, switch to `@plugin` with declarations or a JS config.

Example fix

// before
@config "./tailwind.config.js" {
  /* empty */
}
// after
@config "./tailwind.config.js";
Defensive patterns

Strategy: validation

Validate before calling

function assertConfigNoBody(node) {
  if (node.name === '@config' && node.nodes.length > 0) {
    throw new Error('@config cannot have a body');
  }
}

Prevention

When it happens

Trigger: Writing `@config "./tw.js" { /* anything */ }`. Even an empty `{}` block produces a node list that fails this guard.

Common situations: Confusing `@config` with `@plugin` (which can take option declarations); leftover braces after deleting content.

Related errors


AI-assisted analysis of tailwindlabs/tailwindcss@16e94cbf7f (2026-08-12). Data as JSON: /api/errors/292025f0cc60fb17. Report an issue: GitHub.