shadcn-ui/ui · critical · Error

Generated styles are missing or stale (${missingStyles.join(

Error message

Generated styles are missing or stale (${missingStyles.join(", ")}). Run `pnpm --filter=v4 registry:build --style all` once, then restart the dev server.

What it means

A build-time guard inside next.config.mjs. It reads componentsMap, regex-extracts every `@/styles/<name>/` reference, and verifies `styles/<name>/ui` exists on disk for each. If any referenced style lacks a generated `ui` directory, the build fails fast with a remediation command.

Source

Thrown at apps/v4/next.config.mjs:25

// them. If a tracked map references styles that were never generated locally
// (e.g. after pulling a commit that adds a new base), Turbopack hits hundreds
// of module-not-found errors compiling /docs and the dev server grinds to a
// halt. Fail fast with instructions instead.
if (process.env.NODE_ENV === "development") {
  const componentsMap = path.join(process.cwd(), "registry/__components__.tsx")
  const referencedStyles = existsSync(componentsMap)
    ? new Set(
        [...readFileSync(componentsMap, "utf-8").matchAll(/@\/styles\/([\w-]+)\//g)].map(
          (match) => match[1]
        )
      )
    : new Set(["base-nova"])
  const missingStyles = [...referencedStyles].filter(
    (style) => !existsSync(path.join(process.cwd(), "styles", style, "ui"))
  )

  if (missingStyles.length > 0) {
    throw new Error(
      `Generated styles are missing or stale (${missingStyles.join(", ")}). ` +
        "Run `pnpm --filter=v4 registry:build --style all` once, then restart the dev server."
    )
  }
}

/** @type {import('next').NextConfig} */
const nextConfig = {
  devIndicators: false,
  typescript: {
    ignoreBuildErrors: true,
  },
  experimental: {
    // Rewrite barrel imports to deep imports so a single icon doesn't pull the
    // whole package into the module graph. Next already optimizes lucide-react,
    // @tabler/icons-react, date-fns and lodash-es by default; these are the
    // heavy icon packages this app uses that are NOT on that default list.
    optimizePackageImports: [

View on GitHub (pinned to efac598707)

Solutions

  1. Run `pnpm --filter=v4 registry:build --style all` once, then restart the dev server (exactly as the message says).
  2. If the error persists, confirm the referenced style names by inspecting componentsMap, then build those specifically: `pnpm --filter=v4 registry:build --style <name>`.
  3. For CI, add the registry:build step to the pipeline before next build so `styles/*/ui` is populated.
  4. If you intentionally removed a style, remove its `@/styles/<name>/` imports from componentsMap so it is no longer referenced.

Example fix

# before: build fails
pnpm --filter=v4 dev

# after: generate styles first
pnpm --filter=v4 registry:build --style all
pnpm --filter=v4 dev
Defensive patterns

Strategy: validation

Validate before calling

// Pre-flight: verify every referenced style has a generated ui dir before next build.
import { existsSync, readFileSync } from "node:fs"
import path from "node:path"
const componentsMap = "apps/v4/registry/.../components.json" // path used by next.config
const referenced = existsSync(componentsMap)
  ? new Set([...readFileSync(componentsMap,"utf-8").matchAll(/@\/styles\/([\w-]+)\//g)].map(m => m[1]))
  : new Set(["base-nova"])
const missing = [...referenced].filter(s => !existsSync(path.join(process.cwd(),"styles",s,"ui")))
if (missing.length) {
  console.error(`Missing styles: ${missing.join(", ")}. Run: pnpm --filter=v4 registry:build --style all`)
  process.exit(1)
}

Try / catch

try {
  await build(nextConfig) // next build
} catch (e) {
  if (String(e?.message).includes("Generated styles are missing or stale")) {
    console.error("Run `pnpm --filter=v4 registry:build --style all`, then retry.")
    process.exit(1)
  }
  throw e
}

Prevention

When it happens

Trigger: Running `next dev`/`next build` for v4 when `componentsMap` references a style (e.g. `base-nova`, `new-york`) whose `styles/<name>/ui` output has not been generated. Happens on fresh clone, after switching branches that add a style, or after editing componentsMap to reference a new style.

Common situations: Fresh checkout without running the registry build; CI that skips the registry step; a PR adds a style import without rebuilding; the fallback path where componentsMap is missing defaults to `new Set(["base-nova"])` and that dir is absent.

Related errors


AI-assisted analysis of shadcn-ui/ui@efac598707 (2026-08-12). Data as JSON: /api/errors/58b1c7ea34fee455. Report an issue: GitHub.