{"record":{"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":2515,"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":2497,"sourceCodeEnd":2533,"githubUrl":"https://github.com/vitejs/vite/blob/b4d66fee14d970f45b8a6f3d7d6aee73ca9b88ab/packages/vite/src/node/plugins/css.ts#L2497-L2533","documentation":"Thrown by `loadPreprocessorPath` when Vite cannot resolve a CSS preprocessor package (sass, less, stylus, styl, sugarss) from either the project root or Vite's own install directory. css.ts:2515 names the lang and suggests the install command for the detected package manager. Vite does not bundle preprocessors; they are optional peer deps the user must install.","triggerScenarios":"Source imports a `.scss`/`.sass`/`.less`/`.styl`/`.sugarss` file (or sets a matching `moduleTypes`), Vite calls `loadPreprocessorPath(lang, root)`, `nodeResolveWithVite` returns null for both root and `_dirname`, and line 2515 throws.","commonSituations":"Added a Sass/Less file but did not install the preprocessor. Cloned a repo and ran a partial install that omitted devDeps. Switched from sass to sass-embedded without installing it. Monorepo where the preprocessor is hoisted to a location Vite's resolver cannot reach. CI that prunes devDependencies.","solutions":["Install the named preprocessor as a devDependency: `npm install -D sass` (or sass-embedded, less, stylus, sugarss — use the exact `lang` from the message).","If in a monorepo, install at the workspace root or ensure hoisting reaches the consuming package.","In CI, install with devDependencies included (`npm ci` not `npm ci --omit=dev`).","If you did not intend to use the preprocessor, remove/rename the offending stylesheet extension or convert it to plain CSS.","After installing, clear Vite's cache (`node_modules/.vite`) and restart."],"exampleFix":"// before: App.vue imports <style lang=\"sass\">\n// but neither sass nor sass-embedded is installed\n\n// after\n// $ npm install -D sass-embedded","handlingStrategy":"validation","validationCode":"import { createRequire } from 'node:module'\nconst require = createRequire(import.meta.url)\nconst PREPROCESSORS = ['sass', 'sass-embedded', 'less', 'stylus', 'styl', 'sugarss']\nfunction assertPreprocessorsInstalled(root: string, used: string[]) {\n  for (const lang of used) {\n    try { require.resolve(lang, { paths: [root] }) }\n    catch { throw new Error(`Preprocessor '${lang}' is used but not installed. Run: npm i -D ${lang}`) }\n  }\n}","typeGuard":"function isKnownPreprocessorLang(lang: string): boolean {\n  return ['sass', 'sass-embedded', 'less', 'stylus', 'styl', 'sugarss'].includes(lang)\n}","tryCatchPattern":"try {\n  await build()\n} catch (e) {\n  if (e instanceof Error && /Preprocessor dependency .* not found/.test(e.message)) {\n    const lang = e.message.match(/\"([^\"]+)\" not found/)?.[1]\n    console.error(`Install the missing preprocessor: npm i -D ${lang}`)\n  }\n  throw e\n}","preventionTips":["Install preprocessors (sass/sass-embedded/less/stylus) as devDependencies in every workspace that uses them.","In CI use `npm ci` (not --omit=dev) so devDependencies like sass are present.","Document required preprocessors in the repo README so contributors install them."],"tags":["css","preprocessor","sass","less","stylus","dependencies"],"backgroundTag":null,"analyzedSha":"b4d66fee14d970f45b8a6f3d7d6aee73ca9b88ab","analyzedAt":"2026-08-11T11:49:19.515Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}