shadcn-ui/ui · error · Error
Unknown target " ". Valid targets: .\n\n
Error message
Unknown ${flag} target "${target}". Valid targets: ${valid}.\n\n${USAGE} What it means
assertKnownTarget checks the value passed to --style or --registry against the set of known final style ids (legacy styles like new-york-v4 plus generated base-style combinations like base-nova, radix-nova). Only the literal string "all" bypasses the check. Any other value triggers the throw, appending USAGE so the developer sees the valid id list and flag semantics.
Solutions
- Read the "Valid targets" list in the error and copy a correct id (e.g. base-nova, new-york-v4, or all).
- Use --registry <id> for installable JSON or --style <id> for local generated ui files, per USAGE.
- If you intended a brand-new style, register it in registry/styles + registry/config first, then target it.
Example fix
# before pnpm registry:build --style nova # after pnpm registry:build --style base-nova
Defensive patterns
Strategy: validation
Validate before calling
import { legacyStyles } from "@/registry/_legacy-styles"
import { BASES, STYLES } from "@/registry"
const known = new Set<string>([
...legacyStyles.map((s) => s.name),
...BASES.flatMap((b) => STYLES.map((s) => `${b.name}-${s.name}`)),
])
function assertTarget(flag: string, target: string) {
if (target !== "all" && !known.has(target)) {
throw new Error(`Unknown ${flag} target "${target}". Valid: all, ${[...known].join(", ")}`)
}
} Type guard
function isKnownTarget(target: string, known: Set<string>): boolean {
return target === "all" || known.has(target)
} Prevention
- Run registry:build with no args first; the script logs the style ids it processes.
- Keep a README of current valid style ids and update it when styles are added/renamed.
- In CI, assert the requested id against getKnownStyleNames() before invoking the build.
- Use the exact id form (base-style like base-nova, or legacy like new-york-v4).
When it happens
Trigger: Passing --style nova instead of --style base-nova; passing a base name (radix, base) instead of a full style id; referencing a style id that was renamed or removed; passing a plural or typo'd flag value.
Common situations: After renaming/adding a style without updating muscle memory; stale docs; CI scripts that hard-code an outdated id; muscle-memory shadcn v3 names (default, new-york) used against v4 ids.
Related errors
- Invalid registry namespace
- --style is not supported because it is a legacy source…
- A full project config is required to resolve target aliases.
- Base color " " or theme " " not found
- Base color " " or theme " " not found
AI-assisted analysis of shadcn-ui/ui@efac598707 (2026-08-12).
Data as JSON: /api/errors/f1d280bc14134fca.
Report an issue: GitHub.
Appendix: source
Thrown at apps/v4/scripts/build-registry.mts:180
--style <style|all> Rebuild local generated style files under styles/<style>/ui.
--registry <style|all> Rebuild installable registry JSON under public/r/styles/<style>.
<style> must be "all" or a known final style id (e.g. base-nova, radix-nova, base-sera, new-york-v4).
Flags can be combined, e.g. --style base-nova --registry base-nova.`
function getKnownStyleNames() {
return new Set(getStylesToBuild().map((style) => style.name))
}
function assertKnownTarget(flag: "--style" | "--registry", target: string) {
if (target === "all") {
return
}
const knownStyleNames = getKnownStyleNames()
if (!knownStyleNames.has(target)) {
const valid = ["all", ...Array.from(knownStyleNames)].join(", ")
throw new Error(
`Unknown ${flag} target "${target}". Valid targets: ${valid}.\n\n${USAGE}`
)
}
}
function parseBuildOptions(argv: string[]): BuildOptions {
let values: {
examples?: boolean
indexes?: boolean
style?: string
registry?: string
}
try {
;({ values } = parseArgs({
args: argv,
options: {
examples: { type: "boolean" },View on GitHub (pinned to efac598707)