facebook/docusaurus · error · Error
A Docusaurus plugin is missing a 'name' property.\nNote that
Error message
A Docusaurus plugin is missing a 'name' property.\nNote that even inline/anonymous plugin functions require a 'name' property.
What it means
Thrown during plugin initialization when the plugin returns a non-null object that lacks a `name` property. Docusaurus relies on `name` to namespace plugin content, options, and IDs; anonymous plugins break that contract. Even inline plugin functions must declare a `name`. The check is at plugins/init.ts:158-163.
Source
Thrown at packages/docusaurus/src/server/plugins/init.ts:160
pluginOptions,
);
// Returning null has been explicitly allowed
// It's a way for plugins to self-disable depending on context
// See https://github.com/facebook/docusaurus/pull/10286
if (pluginInstance === null) {
return {config: normalizedPluginConfig, plugin: null};
}
if (pluginInstance === undefined) {
throw new Error(
`A Docusaurus plugin returned 'undefined', which is forbidden.
A plugin is expected to return an object having at least a 'name' property.
If you want a plugin to self-disable depending on context/options, you can explicitly return 'null' instead of 'undefined'`,
);
}
if (!pluginInstance?.name) {
throw new Error(
`A Docusaurus plugin is missing a 'name' property.
Note that even inline/anonymous plugin functions require a 'name' property.`,
);
}
const plugin: InitializedPlugin = {
...pluginInstance,
options: pluginOptions,
version: pluginVersion,
path: path.dirname(normalizedPluginConfig.entryPath),
};
return {
config: normalizedPluginConfig,
plugin,
};
}
View on GitHub (pinned to 3f483e80e3)
Solutions
- Add a stable `name` string to the returned plugin object (e.g. `'my-plugin'`).
- For function plugins, give the function itself a `name` (function declaration) — but explicit `name` in the returned object is safest.
- Use the `Plugin` type from `@docusaurus/types` to make missing `name` a compile error.
Example fix
// before
plugins: [() => ({ loadContent: () => null })],
// after
plugins: [() => ({ name: 'my-plugin', loadContent: () => null })], Defensive patterns
Strategy: type-guard
Validate before calling
function assertPluginName(p: unknown) {
if (!p || typeof (p as any).name !== 'string') {
throw new Error('Plugin object must include a string `name`');
}
} Type guard
function hasPluginName(p: unknown): p is {name: string} {
return typeof p === 'object' && p !== null && typeof (p as any).name === 'string';
} Prevention
- Type plugin returns as `Plugin` from `@docusaurus/types`.
- Always include an explicit `name` in the returned object, not just on the function.
- Add a tiny unit test asserting `name` is present for each plugin.
When it happens
Trigger: Returning `{ loadContent: ... }` without `name`; assigning the plugin object from a spread that omits `name`; an inline plugin function literal whose body returns a nameless object.
Common situations: Quick prototyping an inline plugin in docusaurus.config.js; refactoring a plugin module and dropping the `name` export; copying a snippet that omitted `name`.
Related errors
- A Docusaurus plugin returned 'undefined', which is forbidden
- Plugin "${pluginName}" is used ${pluginInstancesWithId.lengt
- Plugin not found for identifier ${formatPluginName(pluginIde
- Translation file path at "${translationFilePath}" does not n
- You can't use siteConfig.webpack.jsLoader and siteConfig.fut
AI-assisted analysis of facebook/docusaurus@3f483e80e3 (2026-08-12).
Data as JSON: /api/errors/9cb5a7be853689b5.
Report an issue: GitHub.