prisma/prisma · error · ShellConfigError
${file} does not contain a JSON object
Error message
${file} does not contain a JSON object What it means
Thrown by `readJson` when a package.json parses to something that is not a JSON object (e.g. an array, a bare string/number, or `null`). Every consumer of a manifest expects a record; `isRecord` rejects arrays and primitives so downstream field reads do not crash with a confusing type error.
Source
Thrown at packages/0-config/tsdown/shell-build.ts:557
dir = parent;
}
}
/**
* The flat, `__`-separated form of a `/`-separated entry or file name. Build
* outputs are named after this, and `shellExports` maps it back.
*/
function flatEntryName(name: string): string {
return name.replaceAll('/', '__');
}
function isRecord(value: unknown): value is Record<string, unknown> {
return typeof value === 'object' && value !== null && !Array.isArray(value);
}
function readJson(file: string): Record<string, unknown> {
const parsed: unknown = JSON.parse(readFileSync(file, 'utf8'));
if (!isRecord(parsed)) throw new ShellConfigError(`${file} does not contain a JSON object`);
return parsed;
}
function stringField(manifest: Record<string, unknown>, field: string, context: string): string {
const value = manifest[field];
if (typeof value !== 'string') {
throw new ShellConfigError(`package.json of ${context} has no string "${field}" field`);
}
return value;
}
function recordField(manifest: Record<string, unknown>, field: string): Record<string, unknown> {
const value = manifest[field] ?? {};
if (!isRecord(value)) throw new ShellConfigError(`package.json "${field}" is not an object`);
return value;
}
function stringRecordField(View on GitHub (pinned to a20d61fb6f)
Solutions
- Open the named file and ensure its top-level value is a JSON object `{ ... }`.
- Re-run `pnpm install` / regenerate the file if it was machine-produced.
- Validate with `node -e 'JSON.parse(require("fs").readFileSync("<file>","utf8"))'` then fix the structure.
Example fix
// before: <file> contents are [] or null
// after
{
"name": "@internal/foo",
"version": "0.0.0"
} Defensive patterns
Strategy: validation
Validate before calling
import { readFileSync } from 'node:fs';
function readJsonObject(file: string): Record<string, unknown> {
const parsed: unknown = JSON.parse(readFileSync(file, 'utf8'));
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
throw new Error(`${file} does not contain a JSON object`);
}
return parsed as Record<string, unknown>;
} Type guard
function isRecord(value: unknown): value is Record<string, unknown> {
return typeof value === 'object' && value !== null && !Array.isArray(value);
} Prevention
- Validate package.json shape before invoking the shell build.
- Don't hand-edit manifests with tools that can emit arrays/scalars.
When it happens
Trigger: Any package.json read by the shell build (internal package manifests, the shell's own manifest) whose top-level value is `null`, an array, or a scalar. Reached at shell-build.ts:557 inside `readJson`.
Common situations: Corrupted/truncated package.json. A generated package.json that mistakenly emitted a list. Editing accidents that wrapped the object in `[ ... ]`.
Related errors
- unsupported exports value for ${source.name} ${subpath}: ${J
- ${mapping.dir} declares name ${mapping.name} in the shell ma
- ${shellName} package.json is out of sync with its internal p
- package.json of ${context} has no string "${field}" field
- package.json "${field}" is not an object
AI-assisted analysis of prisma/prisma@a20d61fb6f (2026-08-11).
Data as JSON: /api/errors/d2976f24a9637388.
Report an issue: GitHub.