tailwindlabs/tailwindcss · error · Error
`@plugin` must have a path.
Error message
`@plugin` must have a path.
What it means
Thrown when an `@plugin` at-rule has params that, after stripping the surrounding quotes (`node.params.slice(1, -1)`), are zero-length. Tailwind needs a module path to load, so an empty path is rejected.
Source
Thrown at packages/tailwindcss/src/compat/apply-compat-hooks.ts:66
id: string
base: string
reference: boolean
src: SourceLocation | undefined
}[] = []
walk(ast, (node, _ctx) => {
if (node.kind !== 'at-rule') return
let ctx = cssContext(_ctx)
// Collect paths from `@plugin` at-rules
if (node.name === '@plugin') {
if (ctx.parent !== null) {
throw new Error('`@plugin` cannot be nested.')
}
let pluginPath = node.params.slice(1, -1)
if (pluginPath.length === 0) {
throw new Error('`@plugin` must have a path.')
}
let options: CssPluginOptions = {}
for (let decl of node.nodes ?? []) {
if (decl.kind !== 'declaration') {
throw new Error(
`Unexpected \`@plugin\` option:\n\n${toCss([decl])}\n\n\`@plugin\` options must be a flat list of declarations.`,
)
}
if (decl.value === undefined) continue
// Parse the declaration value as a primitive type
// These are the same primitive values supported by JSON
let value: CssPluginOptions[keyof CssPluginOptions] = decl.value
let parts = segment(value, ',').map((part) => {View on GitHub (pinned to 16e94cbf7f)
Solutions
- Provide a valid module path: `@plugin "./my-plugin.js";`.
- If using a template variable, ensure it resolves to a non-empty path before emitting the at-rule.
Example fix
// before @plugin ""; // after @plugin "./my-plugin.js";
Defensive patterns
Strategy: validation
Validate before calling
function assertPluginHasPath(node) {
if (node.name === '@plugin' && node.params.slice(1, -1).length === 0) {
throw new Error('@plugin requires a non-empty path');
}
} Prevention
- Use snippets/templates that always include a sample path for `@plugin`.
- Lint against empty `@plugin` statements in CI.
When it happens
Trigger: Writing `@plugin;` or `@plugin "";`. The slice removes the quote characters; if nothing remains, the guard fires.
Common situations: Typo or incomplete edit leaving the path empty; templating that emits `@plugin "";` when a variable is undefined.
Related errors
- `@plugin` cannot be nested.
- Unexpected `@plugin` option: ${toCss([decl])} `@plugin` op
- Unexpected `@plugin` option: Value of declaration `${toCss([
- `@config` cannot have a body.
- `@config` cannot be nested.
AI-assisted analysis of tailwindlabs/tailwindcss@16e94cbf7f (2026-08-12).
Data as JSON: /api/errors/07749178140369fe.
Report an issue: GitHub.