hexojs/hexo · error · TypeError
name is required
Error message
name is required
What it means
Thrown by Helper.register when the 'name' argument is falsy. Helpers are template-callable functions (e.g. partial, css) indexed by name; an empty name would make the helper unreachable in templates.
Source
Thrown at lib/extend/helper.ts:79
return this.store;
}
/**
* Get helper plugin function by name
* @param {String} name - The name of the helper plugin
* @returns {StoreFunction}
*/
get(name: string): StoreFunction {
return this.store[name];
}
/**
* Register a helper plugin
* @param {String} name - The name of the helper plugin
* @param {StoreFunction} fn - The helper plugin function
*/
register(name: string, fn: StoreFunction): void {
if (!name) throw new TypeError('name is required');
if (typeof fn !== 'function') throw new TypeError('fn must be a function');
this.store[name] = fn;
}
}
export = Helper;
View on GitHub (pinned to 059cb17494)
Solutions
- Pass a non-empty helper name string.
- Validate name presence before registering in loops.
- Ensure the name does not collide with an empty key.
Example fix
// before hexo.extend.helper.register(helperName, fn); // after if (helperName) hexo.extend.helper.register(helperName, fn);
Defensive patterns
Strategy: validation
Validate before calling
if (!name) throw new Error('helper name required');
hexo.extend.helper.register(name, fn); Type guard
const isValidName = (n: unknown): n is string => typeof n === 'string' && n.length > 0;
Prevention
- Register helpers from a typed map and assert keys are non-empty.
- Use a shared helper-registration utility that validates names.
- Test that each helper is reachable in templates after registration.
When it happens
Trigger: Calling hexo.extend.helper.register('', fn) or register(undefined, fn).
Common situations: A plugin registers helpers in a loop over an undefined map, or the helper name is read from a missing config key.
Related errors
AI-assisted analysis of hexojs/hexo@059cb17494 (2026-08-12).
Data as JSON: /api/errors/b80121d74149da6e.
Report an issue: GitHub.