{"id":"294182e5b2bf97e8","repo":"vitejs/vite","slug":"preprocessor-dependency-lang-not-found-did-y","errorCode":null,"errorMessage":"Preprocessor dependency \"${lang}\" not found. Did you install it? Try `${installCommand} -D ${lang}`.","messagePattern":"Preprocessor dependency \"(.+?)\" not found\\. Did you install it\\? Try `(.+?) -D (.+?)`\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vite/src/node/plugins/css.ts","lineNumber":2509,"sourceCode":"\nfunction loadPreprocessorPath(\n  lang: PreprocessLang | PostCssDialectLang | 'sass-embedded',\n  root: string,\n): string {\n  const cached = loadedPreprocessorPath[lang]\n  if (cached) {\n    return cached\n  }\n\n  // Try resolve from project root first, then the current vite installation path\n  const resolved =\n    nodeResolveWithVite(lang, undefined, { root }) ??\n    nodeResolveWithVite(lang, _dirname, { root })\n  if (resolved) return (loadedPreprocessorPath[lang] = resolved)\n\n  // Error if we can't find the preprocessor\n  const installCommand = getPackageManagerCommand('install')\n  throw new Error(\n    `Preprocessor dependency \"${lang}\" not found. Did you install it? Try \\`${installCommand} -D ${lang}\\`.`,\n  )\n}\n\nfunction loadSassPackage(\n  root: string,\n  skipEmbedded = false,\n): {\n  name: 'sass' | 'sass-embedded'\n  path: string\n} {\n  // try sass-embedded before sass, unless skipEmbedded is true\n  if (!skipEmbedded) {\n    try {\n      const path = loadPreprocessorPath('sass-embedded', root)\n      return { name: 'sass-embedded', path }\n    } catch (e1) {\n      try {","sourceCodeStart":2491,"sourceCodeEnd":2527,"githubUrl":"https://github.com/vitejs/vite/blob/89620f09afcfef6b35e7bb8660132ab5b4d0cd3b/packages/vite/src/node/plugins/css.ts#L2491-L2527","documentation":"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.","triggerScenarios":"`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`.","commonSituations":"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.","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."],"exampleFix":"// before — app.scss imported but sass not installed\nimport './app.scss';\n// after\n// npm i -D sass\nimport './app.scss';","handlingStrategy":"validation","validationCode":"import { createRequire } from 'node:module';\nconst require = createRequire(import.meta.url);\n\nfunction ensurePreprocessorInstalled(lang) {\n  try { require.resolve(lang); }\n  catch {\n    throw new Error(`Install missing CSS preprocessor: npm i -D ${lang}`);\n  }\n}\n// const langs = ['sass','less','stylus'].filter(l => usesPreprocessor(l));\n// langs.forEach(ensurePreprocessorInstalled);","typeGuard":null,"tryCatchPattern":"try {\n  await loadPreprocessorPath('sass', root);\n} catch (e) {\n  if (/Preprocessor dependency .* not found/.test(e.message)) {\n    await installMissing('sass'); // npm i -D sass\n  }\n  throw e;\n}","preventionTips":["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."],"tags":["css","preprocessor","sass","less","dependency"],"analyzedSha":"89620f09afcfef6b35e7bb8660132ab5b4d0cd3b","analyzedAt":"2026-08-03T19:28:02.920Z","schemaVersion":2}