vitejs/vite · error · Error
Unknown lang: ${lang}
Error message
Unknown lang: ${lang} What it means
An exhaustiveness guard inside the lightningcss-based CSS dependency resolver. When resolving `@import`/`@use`, the code switches on `lang` (css/styl/sass/scss/less) and the `default` branch throws. The `satisfies never` annotation makes this a compile-time check too; a runtime hit means a lang value slipped through that the switch does not cover.
Source
Thrown at packages/vite/src/node/plugins/css.ts:3378
const lang = CSS_LANGS_RE.exec(from)?.[1] as CssLang | undefined
let resolver: ResolveIdFn
switch (lang) {
case 'css':
case 'sss':
case 'styl':
case 'stylus':
case undefined:
resolver = atImportResolvers.css
break
case 'sass':
case 'scss':
resolver = atImportResolvers.sass
break
case 'less':
resolver = atImportResolvers.less
break
default:
throw new Error(`Unknown lang: ${lang satisfies never}`)
}
const resolved = await resolver(environment, id, from)
if (resolved) {
deps.add(resolved)
return resolved
}
return id
},
},
minify: config.isProduction && !!config.build.cssMinify,
sourceMap:
config.command === 'build'
? !!config.build.sourcemap
: config.css.devSourcemap,
analyzeDependencies: { preserveImports: true },
cssModules: cssModuleRE.test(id)
? (config.css.lightningcss?.cssModules ?? true)View on GitHub (pinned to 89620f09af)
Solutions
- Report the `lang` value from the message — it indicates a Vite-internal or plugin-introduced inconsistency.
- Remove custom plugins that alter CSS file extensions/langs to isolate the cause.
- Update Vite to the latest version; lang-handling bugs are patched regularly.
Defensive patterns
Strategy: try-catch
Try / catch
try {
await transformCss();
} catch (e) {
if (/Unknown lang:/.test(e.message)) {
console.error('Unexpected CSS lang — disable custom CSS lang plugins and update Vite');
}
throw e;
} Prevention
- Avoid custom plugins that mutate CSS file extensions/langs before Vite's resolver runs.
- Keep Vite updated so new CSS dialects are handled.
When it happens
Trigger: Calling the lightningcss `@import` resolver path with a `lang` value outside `{ undefined, 'styl', 'stylus', 'sass', 'scss', 'less' }`. This is gated by `CSS_LANGS_RE`, so it normally only happens with a bug in lang detection.
Common situations: Internal Vite bug after adding a new CSS dialect, a custom plugin that mutates the id extension/lang before this resolver runs, or a malformed lang string in a request.
Related errors
- Unsupported dependency type: ${dep.type}
- HTML proxy index in "${id}" not found
- base or replace is required
- Preprocessor dependency "${lang}" not found. Did you install
- Unsupported target "${e}"
AI-assisted analysis of vitejs/vite@89620f09af (2026-08-03).
Data as JSON: /data/errors/75eb339cc063986a.json.
Report an issue: GitHub.