vitejs/vite · error · Error
Preprocessor dependency "${lang}" not found. Did you install
Error message
Preprocessor dependency "${lang}" not found. Did you install it? Try `${installCommand} -D ${lang}`. What it means
Thrown when Vite tries to load a CSS preprocessor (`sass`, `sass-embedded`, `less`, or `stylus`) but cannot resolve it from the project root or the Vite installation directory. Vite does not bundle these preprocessors, so they must be installed by the project that uses them. The message includes the exact install command for your package manager.
Source
Thrown at packages/vite/src/node/plugins/css.ts:2509
function loadPreprocessorPath(
lang: PreprocessLang | PostCssDialectLang | 'sass-embedded',
root: string,
): string {
const cached = loadedPreprocessorPath[lang]
if (cached) {
return cached
}
// Try resolve from project root first, then the current vite installation path
const resolved =
nodeResolveWithVite(lang, undefined, { root }) ??
nodeResolveWithVite(lang, _dirname, { root })
if (resolved) return (loadedPreprocessorPath[lang] = resolved)
// Error if we can't find the preprocessor
const installCommand = getPackageManagerCommand('install')
throw new Error(
`Preprocessor dependency "${lang}" not found. Did you install it? Try \`${installCommand} -D ${lang}\`.`,
)
}
function loadSassPackage(
root: string,
skipEmbedded = false,
): {
name: 'sass' | 'sass-embedded'
path: string
} {
// try sass-embedded before sass, unless skipEmbedded is true
if (!skipEmbedded) {
try {
const path = loadPreprocessorPath('sass-embedded', root)
return { name: 'sass-embedded', path }
} catch (e1) {
try {View on GitHub (pinned to 89620f09af)
Solutions
- Install the missing preprocessor using the command from the message (e.g. `npm i -D sass` or `npm i -D less`).
- If in a monorepo, ensure the preprocessor is resolvable from the package that runs Vite (install at the workspace or add to that package.json).
- After installing, restart the Vite dev server / rebuild.
- If you do not actually need the preprocessor, stop importing that file type.
Example fix
// before — app.scss imported but sass not installed import './app.scss'; // after // npm i -D sass import './app.scss';
Defensive patterns
Strategy: validation
Validate before calling
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
function ensurePreprocessorInstalled(lang) {
try { require.resolve(lang); }
catch {
throw new Error(`Install missing CSS preprocessor: npm i -D ${lang}`);
}
}
// const langs = ['sass','less','stylus'].filter(l => usesPreprocessor(l));
// langs.forEach(ensurePreprocessorInstalled); Try / catch
try {
await loadPreprocessorPath('sass', root);
} catch (e) {
if (/Preprocessor dependency .* not found/.test(e.message)) {
await installMissing('sass'); // npm i -D sass
}
throw e;
} Prevention
- Install the preprocessor(s) you import: `sass`/`sass-embedded`, `less`, or `stylus`.
- Add a postinstall or CI check that resolves the preprocessor before building.
- In monorepos, install the preprocessor in the package that runs Vite.
When it happens
Trigger: `loadPreprocessorPath(lang, root)` calls `nodeResolveWithVite(lang, ...)` for both root and Vite's own directory; if both return nothing, the error is thrown. `lang` is `sass`, `sass-embedded`, `less`, or `stylus`.
Common situations: Importing a `.scss`/`.sass`/`.less`/`.styl` file for the first time in a project where the preprocessor is not installed; after deleting `node_modules`; a monorepo where the preprocessor is hoisted to a workspace root Vite cannot reach.
Related errors
- Failed to load PostCSS config: ${e}
- Unknown lang: ${lang}
- When "build.cssCodeSplit: false" is set, "rolldownOptions.in
- [vite]: Rolldown failed to resolve import "${exporter}" from
- ?url is not supported with CSS modules. (tried to import ${J
AI-assisted analysis of vitejs/vite@89620f09af (2026-08-03).
Data as JSON: /data/errors/294182e5b2bf97e8.json.
Report an issue: GitHub.