hexojs/hexo · error · TypeError
No input file or string!
Error message
No input file or string!
What it means
First guard in Render.renderSync() (lib/hexo/render.ts:106). renderSync synchronously renders either an inline string (data.text) or a file (data.path). It rejects a falsy data argument outright (null, undefined, 0, '', false) because there is no input to render.
Source
Thrown at lib/hexo/render.ts:106
return Reflect.apply(renderer, ctx, [data, options]);
}).then(result => {
result = toString(result, data);
if (data.onRenderEnd) {
return data.onRenderEnd(result);
}
return result;
}).then(result => {
const output = this.getOutput(ext) || ext;
return ctx.execFilter(`after_render:${output}`, result, {
context: ctx,
args: [data]
});
}).asCallback(callback);
}
renderSync(data: StoreFunctionData, options = {}): any {
if (!data) throw new TypeError('No input file or string!');
const ctx = this.context;
if (data.text == null) {
if (!data.path) throw new TypeError('No input file or string!');
data.text = readFileSync(data.path);
}
if (data.text == null) throw new TypeError('No input file or string!');
const ext = data.engine || getExtname(data.path);
let result;
if (ext && this.isRenderableSync(ext)) {
const renderer = this.getRendererSync(ext);
result = Reflect.apply(renderer, ctx, [data, options]);
} else {
result = data.text;View on GitHub (pinned to 059cb17494)
Solutions
- Pass a StoreFunctionData object: renderSync({ text: '...', engine: 'markdown' }) or renderSync({ path: '...' }).
- Ensure the variable holding data is defined before the call (typeof data === 'object').
- If you only have a string, wrap it: renderSync({ text: str, engine: 'md' }).
Example fix
// before hexo.render.renderSync(maybeInput); // after if (maybeInput) hexo.render.renderSync(maybeInput);
Defensive patterns
Strategy: type-guard
Validate before calling
if (!data || typeof data !== 'object') {
throw new TypeError('renderSync requires a data object with text or path');
}
hexo.render.renderSync(data); Type guard
const isRenderData = (v: unknown): v is { text?: string; path?: string; engine?: string } =>
v != null && typeof v === 'object' && ('text' in v || 'path' in v); Prevention
- Wrap inline strings as { text, engine } before calling renderSync.
- Type the data argument as StoreFunctionData so missing fields fail to compile.
- Avoid optional chaining that can pass undefined into renderSync.
When it happens
Trigger: Calling hexo.render.renderSync(null), renderSync(undefined), or omitting the argument entirely; a code path where the data object was conditionally built and resolved to undefined; passing a string directly instead of wrapping it in { text }.
Common situations: Refactor that made the data object optional; confusion between renderSync(string) and renderSync({ text: string }); optional chaining producing undefined (maybeData && renderSync(maybeData)) when maybeData is null.
Related errors
- name is required
- output is required
- path must be a string!
- path must be a string!
- name must be a string!
AI-assisted analysis of hexojs/hexo@059cb17494 (2026-08-12).
Data as JSON: /api/errors/5190311457c58096.
Report an issue: GitHub.