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(content) throws — the registry file content is not syntactically valid JSON. This is purely a JSON-syntax failure (trailing comma, unquoted key, stray comment, BOM/encoding issue). It is distinct from error 114, which fires when the JSON parses but fails the registry chunk Zod schema. The error is a RegistryParseError with subject 'registry file' and a 'fix the JSON syntax' suggestion.
Source
Thrown at packages/shadcn/src/registry/source.ts:407
message: `Failed to read source registry file at ${formatSourcePath(
registryFile,
options.source
)}.`,
context: { registryFile, source: options.source },
suggestion:
registryFile === "registry.json"
? "Check that the repository has a registry.json file at its root."
: "Check that the included registry.json file exists and that the include 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
- Run the file through a JSON linter or `node -e 'JSON.parse(require("fs").readFileSync("registry.json","utf8"))'` to locate the syntax error.
- Remove comments, trailing commas, and unquoted keys.
- Re-save with UTF-8 (no BOM) encoding.
Example fix
// before — registry.json with trailing comma (invalid JSON)
{
"name": "my-registry",
"homepage": "https://my.dev",
"items": [],
}
// after — trailing comma removed
{
"name": "my-registry",
"homepage": "https://my.dev",
"items": []
} Defensive patterns
Strategy: validation
Validate before calling
function isValidJson(content: string): { ok: true; value: unknown } | { ok: false; error: unknown } {
try {
return { ok: true, value: JSON.parse(content) };
} catch (e) {
return { ok: false, error: e };
}
} Try / catch
import { RegistryParseError } from "@/src/registry/errors";
try {
await loadRegistryItemFromSource(name, reader, opts);
} catch (e) {
if (e instanceof RegistryParseError && /registry file/i.test(e.message)) {
// JSON syntax error; lint the file at e.context.registryFile
}
throw e;
} Prevention
- Use a JSON-aware editor with syntax checking enabled.
- Run a JSON linter (e.g. `jsonlint`) on registry.json in CI.
- Never add comments or trailing commas to registry.json.
When it happens
Trigger: A hand-edited registry.json with a trailing comma, single-quoted string, JS-style comment, or unquoted key; a file with a BOM or mixed encoding; HTML returned instead of JSON in non-source contexts.
Common situations: Manual editing of registry.json without a JSON linter; copy-pasting config snippets that include `//` comments; CRLF/encoding issues from cross-platform editing.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- PARSE_ERROR
- Base color "${baseColorName}" or theme "${themeName}" not fo
- Unknown item: "${designSystemConfig.item}".
- Base color "${config.baseColor}" or theme "${config.theme}"
- Base "${config.base}" or icon library "${config.iconLibrary}
AI-assisted analysis of shadcn-ui/ui@efac598707 (2026-08-12).
Data as JSON: /api/errors/230ad6d1d6984156.
Report an issue: GitHub.