{"record":{"id":"36afe04eb6fe1294","repo":"tailwindlabs/tailwindcss","slug":"tailwind-css-is-not-installed","errorCode":null,"errorMessage":"Tailwind CSS is not installed","messagePattern":"Tailwind CSS is not installed","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@tailwindcss-upgrade/src/utils/version.ts","lineNumber":26,"sourceCode":" *\n * E.g.: `isMajor(3)`\n */\nexport function isMajor(version: number) {\n  return semver.satisfies(installedTailwindVersion(), `>=${version}.0.0 <${version + 1}.0.0`)\n}\n\n/**\n * Must be of greater than the current major version including minor and patch.\n *\n * E.g.: `isGreaterThan(3)`\n */\nexport function isGreaterThan(version: number) {\n  return semver.gte(installedTailwindVersion(), `${version + 1}.0.0`)\n}\n\nlet cache = new DefaultMap((base) => {\n  let tailwindVersion = getPackageVersionSync('tailwindcss', base)\n  if (!tailwindVersion) throw new Error('Tailwind CSS is not installed')\n  return tailwindVersion\n})\n\nexport function installedTailwindVersion(base = process.cwd()): string {\n  return cache.get(base)\n}\n\nlet expectedCache = new DefaultMap((base) => {\n  try {\n    // This will report a problem if the package.json/package-lock.json\n    // mismatches with the installed version in node_modules.\n    //\n    // Also tested this with Bun and PNPM, both seem to work fine.\n    execSync('npm ls tailwindcss --json', { cwd: base, stdio: 'pipe' })\n    return installedTailwindVersion(base)\n  } catch (_e) {\n    try {\n      let e = _e as { stdout: Buffer }","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/tailwindlabs/tailwindcss/blob/16e94cbf7f965c5ad697e90e940b5e178efad67c/packages/@tailwindcss-upgrade/src/utils/version.ts#L8-L44","documentation":"The upgrade tool caches the installed `tailwindcss` version per base directory by reading it via `getPackageVersionSync`. If the package cannot be found in `node_modules` for the given base, the version is unknown and the cache factory throws, since version comparisons (used to drive migration behavior) are meaningless without an install.","triggerScenarios":"Running `@tailwindcss/upgrade` before installing dependencies (`npm install` not yet run), or in a directory whose `node_modules` does not contain `tailwindcss`. The `DefaultMap` factory at version.ts:26 throws when `getPackageVersionSync('tailwindcss', base)` returns falsy.","commonSituations":"Fresh clone without `npm install`, corrupted/incomplete `node_modules`, monorepo where `tailwindcss` is installed in a different workspace, or running the tool against a directory that isn't a Tailwind project.","solutions":["Run `npm install` (or `pnpm install` / `yarn`) in the project root to populate `node_modules`.","Confirm `tailwindcss` is a dependency: `npm ls tailwindcss` and install it if missing.","Ensure the upgrade runs from a directory where `node_modules/tailwindcss` is resolvable."],"exampleFix":"# before\nnpx @tailwindcss/upgrade  # node_modules missing\n\n# after\nnpm install\nnpx @tailwindcss/upgrade","handlingStrategy":"validation","validationCode":"import { existsSync } from 'node:fs'\nimport path from 'node:path'\nfunction assertTailwindInstalled(base = process.cwd()) {\n  let dir = base\n  while (true) {\n    if (existsSync(path.join(dir, 'node_modules', 'tailwindcss', 'package.json'))) return\n    const parent = path.dirname(dir)\n    if (parent === dir) throw new Error('tailwindcss not installed; run npm install')\n    dir = parent\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run npm install before @tailwindcss/upgrade.","Verify with npm ls tailwindcss.","Run the upgrade from a directory that resolves node_modules/tailwindcss."],"tags":["upgrade","dependency","environment"],"backgroundTag":null,"analyzedSha":"16e94cbf7f965c5ad697e90e940b5e178efad67c","analyzedAt":"2026-08-12T06:02:42.469Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}