Meituan-Dianping/mpvue · error · Error
renderSync cannot be called without a template.
Error message
renderSync cannot be called without a template.
What it means
Generic guard thrown by TemplateRenderer.renderSync when the renderer was constructed without a template option. renderSync needs a parsed HTML template to interpolate the rendered app content and context into; without one there is nothing to inject into, so the call is invalid rather than a runtime failure.
Source
Thrown at src/server/template-renderer/index.js:84
// initial async chunk mapping
this.mapFiles = createMapper(clientManifest)
}
}
bindRenderFns (context: Object) {
const renderer: any = this
;['ResourceHints', 'State', 'Scripts', 'Styles'].forEach(type => {
context[`render${type}`] = renderer[`render${type}`].bind(renderer, context)
})
// also expose getPreloadFiles, useful for HTTP/2 push
context.getPreloadFiles = renderer.getPreloadFiles.bind(renderer, context)
}
// render synchronously given rendered app content and render context
renderSync (content: string, context: ?Object) {
const template = this.parsedTemplate
if (!template) {
throw new Error('renderSync cannot be called without a template.')
}
context = context || {}
if (this.inject) {
return (
template.head(context) +
(context.head || '') +
this.renderResourceHints(context) +
this.renderStyles(context) +
template.neck(context) +
content +
this.renderState(context) +
this.renderScripts(context) +
template.tail(context)
)
} else {
return (
template.head(context) +
template.neck(context) +View on GitHub (pinned to 6c5d78ee04)
Solutions
- Pass a template (file path or HTML string) when creating the renderer: createRenderer({ template })
- For no-template usage, call renderToString/renderToStream directly instead of renderSync
- Verify the template option is not undefined due to a failed fs.readFileSync
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/server/template-renderer/index.js:84 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Meituan-Dianping/mpvue@6c5d78ee04 (2026-09-02).
Data as JSON: /api/errors/9ec0f60eea6a70c6.
Report an issue: GitHub.