tailwindlabs/tailwindcss · error · Error

Tailwind CSS is not installed

Error message

Tailwind CSS is not installed

What it means

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.

Source

Thrown at packages/@tailwindcss-upgrade/src/utils/version.ts:26

 *
 * E.g.: `isMajor(3)`
 */
export function isMajor(version: number) {
  return semver.satisfies(installedTailwindVersion(), `>=${version}.0.0 <${version + 1}.0.0`)
}

/**
 * Must be of greater than the current major version including minor and patch.
 *
 * E.g.: `isGreaterThan(3)`
 */
export function isGreaterThan(version: number) {
  return semver.gte(installedTailwindVersion(), `${version + 1}.0.0`)
}

let cache = new DefaultMap((base) => {
  let tailwindVersion = getPackageVersionSync('tailwindcss', base)
  if (!tailwindVersion) throw new Error('Tailwind CSS is not installed')
  return tailwindVersion
})

export function installedTailwindVersion(base = process.cwd()): string {
  return cache.get(base)
}

let expectedCache = new DefaultMap((base) => {
  try {
    // This will report a problem if the package.json/package-lock.json
    // mismatches with the installed version in node_modules.
    //
    // Also tested this with Bun and PNPM, both seem to work fine.
    execSync('npm ls tailwindcss --json', { cwd: base, stdio: 'pipe' })
    return installedTailwindVersion(base)
  } catch (_e) {
    try {
      let e = _e as { stdout: Buffer }

View on GitHub (pinned to 16e94cbf7f)

Solutions

  1. Run `npm install` (or `pnpm install` / `yarn`) in the project root to populate `node_modules`.
  2. Confirm `tailwindcss` is a dependency: `npm ls tailwindcss` and install it if missing.
  3. Ensure the upgrade runs from a directory where `node_modules/tailwindcss` is resolvable.

Example fix

# before
npx @tailwindcss/upgrade  # node_modules missing

# after
npm install
npx @tailwindcss/upgrade
Defensive patterns

Strategy: validation

Validate before calling

import { existsSync } from 'node:fs'
import path from 'node:path'
function assertTailwindInstalled(base = process.cwd()) {
  let dir = base
  while (true) {
    if (existsSync(path.join(dir, 'node_modules', 'tailwindcss', 'package.json'))) return
    const parent = path.dirname(dir)
    if (parent === dir) throw new Error('tailwindcss not installed; run npm install')
    dir = parent
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of tailwindlabs/tailwindcss@16e94cbf7f (2026-08-12). Data as JSON: /api/errors/36afe04eb6fe1294. Report an issue: GitHub.