hexojs/hexo · error · TypeError
name is required
Error message
name is required
What it means
Thrown by Renderer.register when the 'name' argument is falsy. Renderers convert one file extension to another (e.g. md -> html); the name is the input extension and is required to look the renderer up by path.
Source
Thrown at lib/extend/renderer.ts:101
isRenderable(path: string): boolean {
return Boolean(this.get(path));
}
isRenderableSync(path: string): boolean {
return Boolean(this.get(path, true));
}
getOutput(path: string): string {
const renderer = this.get(path);
return renderer ? renderer.output : '';
}
register(name: string, output: string, fn: StoreFunctionWithCallback): void;
register(name: string, output: string, fn: StoreFunctionWithCallback, sync: false): void;
register(name: string, output: string, fn: StoreSyncFunction, sync: true): void;
register(name: string, output: string, fn: StoreFunctionWithCallback | StoreSyncFunction, sync: boolean): void;
register(name: string, output: string, fn: StoreFunctionWithCallback | StoreSyncFunction, sync?: boolean) {
if (!name) throw new TypeError('name is required');
if (!output) throw new TypeError('output is required');
if (typeof fn !== 'function') throw new TypeError('fn must be a function');
name = getExtname(name);
output = getExtname(output);
if (sync) {
this.storeSync[name] = fn;
this.storeSync[name].output = output;
this.store[name] = Promise.method(fn);
this.store[name].disableNunjucks = (fn as StoreFunction).disableNunjucks;
} else {
if (fn.length > 2) fn = Promise.promisify(fn);
this.store[name] = fn;
}
this.store[name].output = output;View on GitHub (pinned to 059cb17494)
Solutions
- Pass a non-empty name (input extension, e.g. 'md', 'styl', 'ejs').
- Validate the extension source before registering.
- Note the name is later passed through getExtname, so include the leading dot or extension.
Example fix
// before hexo.extend.renderer.register(ext, 'html', fn); // after if (ext) hexo.extend.renderer.register(ext, 'html', fn);
Defensive patterns
Strategy: validation
Validate before calling
if (!name) throw new Error('renderer input name required');
hexo.extend.renderer.register(name, output, fn); Type guard
const isValidName = (n: unknown): n is string => typeof n === 'string' && n.length > 0;
Prevention
- Pass the input extension (e.g. 'md') explicitly rather than from loose config.
- Validate both name and output in a shared registerRenderer helper.
- Test get(path) returns the renderer after registration.
When it happens
Trigger: Calling hexo.extend.renderer.register('', 'html', fn) or register(undefined, 'html', fn).
Common situations: A renderer plugin derives the input extension from config that is empty, or passes a variable that is unset.
Related errors
AI-assisted analysis of hexojs/hexo@059cb17494 (2026-08-12).
Data as JSON: /api/errors/b2adb341b9662964.
Report an issue: GitHub.