shadcn-ui/ui · error · Error

\n\n

Error message

${(error as Error).message}\n\n${USAGE}

What it means

parseBuildOptions calls Node's parseArgs with strict:true and allowPositionals:false over a fixed option schema (--examples/--indexes/--style/--registry). parseArgs throws on unknown flags, flags missing a value, repeated boolean flags, or any positional argument. The catch wraps the native message and appends USAGE so the cause and the correct invocation are visible together.

Solutions

  1. Read the wrapped message — parseArgs states the exact problem (e.g. 'unknown option' or 'expected value').
  2. Restrict to the four supported flags and give --style/--registry a value.
  3. Do not pass positional arguments; everything must be a named flag.

Example fix

# before
pnpm registry:build --styles base-nova ./extra

# after
pnpm registry:build --style base-nova
Defensive patterns

Strategy: validation

Validate before calling

import { parseArgs } from "util"
const ALLOWED = new Set(["examples", "indexes", "style", "registry"])
// pre-check argv tokens before parseArgs
for (const tok of argv) {
  const name = tok.startsWith("--") ? tok.replace(/^--/, "").split("=")[0] : null
  if (name && !ALLOWED.has(name)) throw new Error(`Unknown flag --${name}`)
}

Type guard

function isAllowedFlag(tok: string): boolean {
  if (!tok.startsWith("--")) return true
  const name = tok.replace(/^--/, "").split("=")[0]
  return new Set(["examples", "indexes", "style", "registry"]).has(name)
}

Prevention

When it happens

Trigger: Passing an unknown flag (--styles plural, --target); --style with no following value; --examples=foo (boolean flag given a value); passing a bare positional path argument (rejected because allowPositionals:false).

Common situations: Typo'd flag name; copy-pasting an outdated CLI invocation from docs; passing a file path positionally by habit.

Related errors


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

Appendix: source

Thrown at apps/v4/scripts/build-registry.mts:207

    indexes?: boolean
    style?: string
    registry?: string
  }

  try {
    ;({ values } = parseArgs({
      args: argv,
      options: {
        examples: { type: "boolean" },
        indexes: { type: "boolean" },
        style: { type: "string" },
        registry: { type: "string" },
      },
      allowPositionals: false,
      strict: true,
    }))
  } catch (error) {
    throw new Error(`${(error as Error).message}\n\n${USAGE}`)
  }

  if (values.style !== undefined) {
    assertKnownTarget("--style", values.style)
  }
  if (values.registry !== undefined) {
    assertKnownTarget("--registry", values.registry)
  }

  return {
    examples: values.examples ?? false,
    indexes: values.indexes ?? false,
    style: values.style ?? null,
    registry: values.registry ?? null,
  }
}

function isFullBuild(options: BuildOptions) {

View on GitHub (pinned to efac598707)