hexojs/hexo · error · TypeError

name is required

Error message

name is required

What it means

Thrown by Migrator.register when the 'name' argument is falsy. Migrators import content from other platforms and are selected by name on the CLI; an empty name makes the migrator unusable.

Source

Thrown at lib/extend/migrator.ts:32

 * A migrator helps users migrate from other systems to Hexo.
 */
class Migrator {
  public store: Store;

  constructor() {
    this.store = {};
  }

  list(): Store {
    return this.store;
  }

  get(name: string): StoreFunction {
    return this.store[name];
  }

  register(name: string, fn: (this: Hexo, args: any, callback?: NodeJSLikeCallback<any>) => any): void {
    if (!name) throw new TypeError('name is required');
    if (typeof fn !== 'function') throw new TypeError('fn must be a function');

    if (fn.length > 1) {
      fn = Promise.promisify(fn);
    } else {
      fn = Promise.method(fn);
    }

    this.store[name] = fn;
  }
}

export = Migrator;

View on GitHub (pinned to 059cb17494)

Solutions

  1. Pass a non-empty migrator name string.
  2. Validate the name source before registering.
  3. Ensure the name is unique among registered migrators.

Example fix

// before
hexo.extend.migrator.register(name, fn);
// after
if (name) hexo.extend.migrator.register(name, fn);
Defensive patterns

Strategy: validation

Validate before calling

if (!name) throw new Error('migrator name required');
hexo.extend.migrator.register(name, fn);

Type guard

const isValidName = (n: unknown): n is string => typeof n === 'string' && n.length > 0;

Prevention

When it happens

Trigger: Calling hexo.extend.migrator.register('', fn) or register(undefined, fn).

Common situations: A migrator plugin reads its name from a package field that is empty, or passes a variable that was never assigned.

Related errors


AI-assisted analysis of hexojs/hexo@059cb17494 (2026-08-12). Data as JSON: /api/errors/dfb6da4f055bf244. Report an issue: GitHub.