parcel-bundler/parcel · error · ThrowableDiagnostic
Unknown template language: "${template.lang}"
Error message
Unknown template language: "${template.lang}" What it means
Thrown by @parcel/transformer-vue when a <template lang="..."> uses a language other than html/htm and consolidate has no matching preprocessor (consolidate[template.lang] is undefined). The transformer looks up the renderer in the consolidate library to convert the template source to HTML before compileTemplate runs.
Source
Thrown at packages/transformers/vue/src/VueTransformer.js:238
await options.inputFS.readFile(
await resolve(asset.filePath, template.src),
)
).toString();
template.lang = extname(template.src).slice(1);
}
let content = template.content;
if (template.lang && !['htm', 'html'].includes(template.lang)) {
let options = {};
let preprocessor = consolidate[template.lang];
// Pug doctype fix (fixes #7756)
switch (template.lang) {
case 'pug':
options.doctype = 'html';
break;
}
if (!preprocessor) {
// TODO: codeframe
throw new ThrowableDiagnostic({
diagnostic: {
message: md`Unknown template language: "${template.lang}"`,
origin: '@parcel/transformer-vue',
},
});
}
content = await preprocessor.render(content, options);
}
let templateComp = compiler.compileTemplate({
filename: asset.filePath,
source: content,
inMap: template.src ? undefined : template.map,
scoped: styles.some(style => style.scoped),
isFunctional,
compilerOptions: {
...config.compilerOptions,
bindingMetadata: script ? script.bindings : undefined,
},View on GitHub (pinned to 59484858a1)
Solutions
- Install the missing template engine: `npm install pug` (and ensure @parcel/transformer-vue depends on consolidate).
- Correct the lang attribute to a supported consolidate engine name.
- Drop the lang attribute to use plain HTML if no preprocessor is needed.
Example fix
// before <template lang="pug">div</template> <!-- pug not installed --> // after <template lang="pug">div</template> <!-- after `npm i pug` --> // or <template><div/></template>
Defensive patterns
Strategy: validation
Validate before calling
import consolidate from 'consolidate';
const lang = template.lang;
if (lang && !['htm','html'].includes(lang) && !consolidate[lang]) {
throw new Error(`Template lang '${lang}' has no consolidate preprocessor; install it or remove the lang attribute.`);
} Type guard
function isSupportedTemplateLang(lang) {
return !lang || ['htm','html'].includes(lang) || Boolean(consolidate[lang]);
} Prevention
- Install the engine package (pug, handlebars, ejs) before setting template lang.
- Use only lang names that exist as keys on consolidate.
- Default to plain HTML when no preprocessing is required.
When it happens
Trigger: template.lang is set to a value (pug, handlebars, ejs, etc.) but the corresponding consolidate engine — or its underlying npm package — is not installed, so consolidate[lang] is undefined.
Common situations: Using `<template lang="pug">` without installing pug, or a lang value consolidate doesn't ship a key for (typo like 'pugjs' or a niche engine not bundled). Removing a previously-installed preprocessor breaks builds retroactively.
Related errors
- [dynamic diagnostic from Vue template compiler errors]
- Vue config should be an object.
- [dynamic diagnostic from Vue compiler parse errors]
- Unknown script language: "${script.lang}"
- Unknown style language: "${style.lang}"
AI-assisted analysis of parcel-bundler/parcel@59484858a1 (2026-08-13).
Data as JSON: /api/errors/da3b64aa553c4585.
Report an issue: GitHub.