{"record":{"id":"58b1c7ea34fee455","repo":"shadcn-ui/ui","slug":"generated-styles-are-missing-or-stale-missingst","errorCode":null,"errorMessage":"Generated styles are missing or stale (${missingStyles.join(\", \")}). Run `pnpm --filter=v4 registry:build --style all` once, then restart the dev server.","messagePattern":"Generated styles are missing or stale \\((.+?)\\)\\. Run `pnpm --filter=v4 registry:build --style all` once, then restart the dev server\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"apps/v4/next.config.mjs","lineNumber":25,"sourceCode":"// them. If a tracked map references styles that were never generated locally\n// (e.g. after pulling a commit that adds a new base), Turbopack hits hundreds\n// of module-not-found errors compiling /docs and the dev server grinds to a\n// halt. Fail fast with instructions instead.\nif (process.env.NODE_ENV === \"development\") {\n  const componentsMap = path.join(process.cwd(), \"registry/__components__.tsx\")\n  const referencedStyles = existsSync(componentsMap)\n    ? new Set(\n        [...readFileSync(componentsMap, \"utf-8\").matchAll(/@\\/styles\\/([\\w-]+)\\//g)].map(\n          (match) => match[1]\n        )\n      )\n    : new Set([\"base-nova\"])\n  const missingStyles = [...referencedStyles].filter(\n    (style) => !existsSync(path.join(process.cwd(), \"styles\", style, \"ui\"))\n  )\n\n  if (missingStyles.length > 0) {\n    throw new Error(\n      `Generated styles are missing or stale (${missingStyles.join(\", \")}). ` +\n        \"Run `pnpm --filter=v4 registry:build --style all` once, then restart the dev server.\"\n    )\n  }\n}\n\n/** @type {import('next').NextConfig} */\nconst nextConfig = {\n  devIndicators: false,\n  typescript: {\n    ignoreBuildErrors: true,\n  },\n  experimental: {\n    // Rewrite barrel imports to deep imports so a single icon doesn't pull the\n    // whole package into the module graph. Next already optimizes lucide-react,\n    // @tabler/icons-react, date-fns and lodash-es by default; these are the\n    // heavy icon packages this app uses that are NOT on that default list.\n    optimizePackageImports: [","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/shadcn-ui/ui/blob/efac5987074af84ece57c367c6dd83387b967022/apps/v4/next.config.mjs#L7-L43","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run `pnpm --filter=v4 registry:build --style all` once, then restart the dev server (exactly as the message says).","If the error persists, confirm the referenced style names by inspecting componentsMap, then build those specifically: `pnpm --filter=v4 registry:build --style <name>`.","For CI, add the registry:build step to the pipeline before next build so `styles/*/ui` is populated.","If you intentionally removed a style, remove its `@/styles/<name>/` imports from componentsMap so it is no longer referenced."],"exampleFix":"# before: build fails\npnpm --filter=v4 dev\n\n# after: generate styles first\npnpm --filter=v4 registry:build --style all\npnpm --filter=v4 dev","handlingStrategy":"validation","validationCode":"// Pre-flight: verify every referenced style has a generated ui dir before next build.\nimport { existsSync, readFileSync } from \"node:fs\"\nimport path from \"node:path\"\nconst componentsMap = \"apps/v4/registry/.../components.json\" // path used by next.config\nconst referenced = existsSync(componentsMap)\n  ? new Set([...readFileSync(componentsMap,\"utf-8\").matchAll(/@\\/styles\\/([\\w-]+)\\//g)].map(m => m[1]))\n  : new Set([\"base-nova\"])\nconst missing = [...referenced].filter(s => !existsSync(path.join(process.cwd(),\"styles\",s,\"ui\")))\nif (missing.length) {\n  console.error(`Missing styles: ${missing.join(\", \")}. Run: pnpm --filter=v4 registry:build --style all`)\n  process.exit(1)\n}","typeGuard":null,"tryCatchPattern":"try {\n  await build(nextConfig) // next build\n} catch (e) {\n  if (String(e?.message).includes(\"Generated styles are missing or stale\")) {\n    console.error(\"Run `pnpm --filter=v4 registry:build --style all`, then retry.\")\n    process.exit(1)\n  }\n  throw e\n}","preventionTips":["Add `pnpm --filter=v4 registry:build --style all` to your dev setup script and CI before next build/dev.","After switching branches that touch styles or componentsMap, rebuild the registry.","If you remove a style, also remove its @/styles/<name>/ imports from componentsMap."],"tags":["nextjs","build","registry","styles","shadcn-v4","config"],"backgroundTag":null,"analyzedSha":"efac5987074af84ece57c367c6dd83387b967022","analyzedAt":"2026-08-12T05:00:50.218Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}