{"record":{"id":"869afbf228bfe126","repo":"payloadcms/payload","slug":"no-package-json-found-in-this-project","errorCode":null,"errorMessage":"No package.json found in this project","messagePattern":"No package\\.json found in this project","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/create-payload-app/src/lib/update-payload-in-project.ts","lineNumber":136,"sourceCode":"  appDetails: NextAppDetails,\n  versionOrTag?: string,\n): Promise<UpdateResult> {\n  return updatePayloadInNextProject({ appDetails, versionOrTag })\n}\n\nasync function performPayloadPackageUpdate({\n  projectDir,\n  versionOrTag,\n}: {\n  projectDir: string\n  versionOrTag?: string\n}): Promise<PackageUpdateResult> {\n  const packageObj = (await fse.readJson(path.resolve(projectDir, 'package.json'))) as {\n    dependencies?: Record<string, string>\n    devDependencies?: Record<string, string>\n  }\n  if (!packageObj.dependencies && !packageObj.devDependencies) {\n    throw new Error('No package.json found in this project')\n  }\n\n  const dependencyGroups = [packageObj.dependencies, packageObj.devDependencies].filter(\n    (dependencies): dependencies is Record<string, string> => Boolean(dependencies),\n  )\n  const payloadPackageEntries = dependencyGroups.flatMap((dependencies) =>\n    Object.entries(dependencies).filter(\n      ([packageName]) => packageName === 'payload' || packageName.startsWith('@payloadcms/'),\n    ),\n  )\n  const payloadVersion = payloadPackageEntries.find(\n    ([packageName]) => packageName === 'payload',\n  )?.[1]\n  if (!payloadVersion) {\n    throw new Error('Payload is not installed in this project')\n  }\n\n  const packageManager = await getPackageManager({ projectDir })","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/create-payload-app/src/lib/update-payload-in-project.ts#L118-L154","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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)."],"exampleFix":"// before — package.json\n{\n  \"name\": \"my-app\",\n  \"version\": \"1.0.0\"\n}\n\n// after\n{\n  \"name\": \"my-app\",\n  \"version\": \"1.0.0\",\n  \"dependencies\": {},\n  \"devDependencies\": {}\n}","handlingStrategy":"validation","validationCode":"import fse from 'fs-extra'\nimport path from 'path'\n\nasync function assertPackageJsonHasDeps(projectDir: string) {\n  const pkg = await fse.readJson(path.resolve(projectDir, 'package.json'))\n  if (!pkg.dependencies && !pkg.devDependencies) {\n    throw new Error('package.json has no dependencies or devDependencies — wrong project root?')\n  }\n}","typeGuard":"function hasDeps(pkg: unknown): pkg is { dependencies?: Record<string, string>; devDependencies?: Record<string, string> } {\n  return typeof pkg === 'object' && pkg !== null && ('dependencies' in pkg || 'devDependencies' in pkg)\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["create-payload-app","cli","config","package-json"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}