payloadcms/payload · error · Error
No package.json found in this project
Error message
No package.json found in this project
What it means
performPayloadPackageUpdate reads projectDir/package.json via fse.readJson (which would throw on missing file), then throws this when the parsed object has neither dependencies nor devDependencies. Note the message is misleading: the file exists; it just contains no dependency groups.
Source
Thrown at packages/create-payload-app/src/lib/update-payload-in-project.ts:136
appDetails: NextAppDetails,
versionOrTag?: string,
): Promise<UpdateResult> {
return updatePayloadInNextProject({ appDetails, versionOrTag })
}
async function performPayloadPackageUpdate({
projectDir,
versionOrTag,
}: {
projectDir: string
versionOrTag?: string
}): Promise<PackageUpdateResult> {
const packageObj = (await fse.readJson(path.resolve(projectDir, 'package.json'))) as {
dependencies?: Record<string, string>
devDependencies?: Record<string, string>
}
if (!packageObj.dependencies && !packageObj.devDependencies) {
throw new Error('No package.json found in this project')
}
const dependencyGroups = [packageObj.dependencies, packageObj.devDependencies].filter(
(dependencies): dependencies is Record<string, string> => Boolean(dependencies),
)
const payloadPackageEntries = dependencyGroups.flatMap((dependencies) =>
Object.entries(dependencies).filter(
([packageName]) => packageName === 'payload' || packageName.startsWith('@payloadcms/'),
),
)
const payloadVersion = payloadPackageEntries.find(
([packageName]) => packageName === 'payload',
)?.[1]
if (!payloadVersion) {
throw new Error('Payload is not installed in this project')
}
const packageManager = await getPackageManager({ projectDir })View on GitHub (pinned to 00c58b35c0)
Solutions
- Confirm you are pointing at the real project root that contains a populated package.json.
- Ensure package.json has at least a dependencies or devDependencies object (even empty {}).
- If Payload is not yet installed, use the create/init flow rather than the update flow.
- Validate the file parses as valid JSON (fse.readJson would throw separately if malformed).
Example fix
// before — package.json
{
"name": "my-app",
"version": "1.0.0"
}
// after
{
"name": "my-app",
"version": "1.0.0",
"dependencies": {},
"devDependencies": {}
} Defensive patterns
Strategy: validation
Validate before calling
import fse from 'fs-extra'
import path from 'path'
async function assertPackageJsonHasDeps(projectDir: string) {
const pkg = await fse.readJson(path.resolve(projectDir, 'package.json'))
if (!pkg.dependencies && !pkg.devDependencies) {
throw new Error('package.json has no dependencies or devDependencies — wrong project root?')
}
} Type guard
function hasDeps(pkg: unknown): pkg is { dependencies?: Record<string, string>; devDependencies?: Record<string, string> } {
return typeof pkg === 'object' && pkg !== null && ('dependencies' in pkg || 'devDependencies' in pkg)
} Prevention
- Confirm projectDir points at the real project root.
- Keep a dependencies (or devDependencies) object in package.json even when empty.
- Use the init flow, not update, when Payload is not yet installed.
When it happens
Trigger: Running the Payload update/init flow in a directory whose package.json has no dependencies and no devDependencies keys (e.g. a freshly npm init -y package, or a package.json containing only scripts/metadata).
Common situations: Targeting the wrong projectDir (not the project root); a monorepo child package with no deps; a hand-edited package.json that dropped the dependencies block; running update before any Payload install.
Related errors
- Payload is not installed in this project
- Invalid template given
- Invalid database type given. Valid types are: ${Object.value
- Failed to download: ${url}
- Failed to download: ${url}
AI-assisted analysis of payloadcms/payload@00c58b35c0 (2026-08-12).
Data as JSON: /api/errors/869afbf228bfe126.
Report an issue: GitHub.