hexojs/hexo · error · TypeError

output is required

Error message

output is required

What it means

Thrown by Renderer.register when the 'output' argument is falsy. The output is the target extension the renderer produces; without it Hexo cannot determine the rendered file's type.

Source

Thrown at lib/extend/renderer.ts:102

    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;
    this.store[name].compile = fn.compile;

View on GitHub (pinned to 059cb17494)

Solutions

  1. Pass a non-empty output extension (e.g. 'html', 'css').
  2. Confirm the (name, output, fn) argument order is correct.
  3. Validate the output source before registering.

Example fix

// before
hexo.extend.renderer.register('styl', out, fn);
// after
hexo.extend.renderer.register('styl', 'css', fn);
Defensive patterns

Strategy: validation

Validate before calling

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

Type guard

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

Prevention

When it happens

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

Common situations: A plugin author passes the input extension but forgets the output extension, or reads output from a missing config field.

Related errors


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