shadcn-ui/ui · error · RegistryParseError

PARSE_ERROR

PARSE_ERROR

Error message

Failed to parse registry file: ${registryFile}

What it means

Thrown by parseRegistry when JSON.parse rejects the registry file contents. This is a syntax-level failure (malformed JSON), distinct from error 87 which is a schema failure. The original parse error is attached as cause. The library treats any unparseable registry as fatal because no downstream validation can proceed.

Source

Thrown at packages/shadcn/src/registry/loader.ts:408

async function readRegistryJson(registryFile: string) {
  try {
    return await fs.readFile(registryFile, "utf-8")
  } catch (error) {
    throw new RegistryLocalFileError(registryFile, error, {
      message: `Failed to read registry file at ${registryFile}.`,
      context: { registryFile },
      suggestion:
        "Check that the registry.json file exists and that the path is correct.",
    })
  }
}

function parseRegistry(content: string, registryFile: string) {
  let json: unknown
  try {
    json = JSON.parse(content)
  } catch (error) {
    throw new RegistryParseError(registryFile, error, {
      subject: "registry file",
      context: { registryFile },
      suggestion:
        "Fix the JSON syntax in the registry.json file and try again.",
    })
  }

  const result = registryChunkSchema.safeParse(json)
  if (!result.success) {
    throw new RegistryValidationError(
      `Invalid registry file at ${registryFile}:\n${formatZodIssues(
        result.error
      )}`,
      {
        registryFile,
        cause: result.error,
        suggestion:
          "Update the registry.json file so it matches the registry schema.",

View on GitHub (pinned to efac598707)

Solutions

  1. Open the registryFile shown in the error and run it through a JSON validator (e.g. JSON.parse in a REPL, or a linter).
  2. Remove trailing commas, comments, and single quotes; quote all keys.
  3. Resolve git merge conflicts fully (no >>> ==== <<< markers).
  4. Re-serialize the file from a known-good object (JSON.stringify(obj, null, 2)).

Example fix

// before - invalid JSON
{
  "name": "my-registry",
  "homepage": "https://example.com",  // trailing comma
  "items": [
    { "name": "button", }
  ]
}

// after
{
  "name": "my-registry",
  "homepage": "https://example.com",
  "items": [
    { "name": "button" }
  ]
}
Defensive patterns

Strategy: validation

Validate before calling

function assertValidJson(content: string, file: string) {
  try {
    JSON.parse(content)
  } catch (e) {
    throw new Error(`${file} is not valid JSON: ${(e as Error).message}`)
  }
}

// before loadRegistry:
assertValidJson(await fs.readFile(registryFile, "utf-8"), registryFile)

Try / catch

try {
  await loadRegistry({ registryFile })
} catch (err) {
  if (err instanceof RegistryParseError) {
    // err.cause is the original SyntaxError; fix the JSON
  }
  throw err
}

Prevention

When it happens

Trigger: A registry.json that is not valid JSON: trailing commas, single quotes, unquoted keys, comments, control characters, or a truncated file. JSON.parse(content) throws and the catch wraps it into RegistryParseError with code PARSE_ERROR.

Common situations: Hand-editing registry.json and leaving a trailing comma or comment. File truncated by a failed write or git conflict markers left in. Copy-pasting from a JS/TS source that used unquoted keys. A build tool that emitted JSON5. Editor inserting a BOM or smart quotes.

Understand the failure class

Related errors


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