{"record":{"id":"7ea88aef2dc53985","repo":"ruvnet/ruflo","slug":"package-json-not-found-7ea88a","errorCode":null,"errorMessage":"package.json not found","messagePattern":"package\\.json not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/deployment/src/release-manager.ts","lineNumber":82,"sourceCode":"      commit = true,\n      dryRun = false,\n      skipValidation = false,\n      tagPrefix = 'v',\n      changelogPath = 'CHANGELOG.md'\n    } = options;\n\n    const result: ReleaseResult = {\n      oldVersion: '',\n      newVersion: '',\n      success: false,\n      warnings: []\n    };\n\n    try {\n      // Read package.json\n      const pkgPath = join(this.cwd, 'package.json');\n      if (!existsSync(pkgPath)) {\n        throw new Error('package.json not found');\n      }\n\n      const pkg: PackageInfo = JSON.parse(readFileSync(pkgPath, 'utf-8'));\n      result.oldVersion = pkg.version;\n\n      // Check for uncommitted changes\n      if (!skipValidation) {\n        const gitStatus = this.execCommand('git status --porcelain', true);\n        if (gitStatus && !dryRun) {\n          result.warnings?.push('Uncommitted changes detected');\n        }\n      }\n\n      // Determine new version\n      result.newVersion = version || this.bumpVersion(pkg.version, bumpType, channel);\n\n      // Generate changelog if requested\n      if (generateChangelog) {","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/deployment/src/release-manager.ts#L64-L100","documentation":"ReleaseManager.prepareRelease() reads package.json from the directory passed to new ReleaseManager(cwd) — defaulting to process.cwd() — and throws before touching git or versions if it is missing. The recorded failure lands in result.error with success: false rather than propagating as an exception.","triggerScenarios":"new ReleaseManager('/wrong/dir').prepareRelease(); running the release CLI from a monorepo root when the package lives in a subdirectory; a typo in the cwd argument.","commonSituations":"Monorepos with packages in subdirectories; CI invoking release from the repository root; scripts reusing a workspace root path for all tools.","solutions":["Construct the ReleaseManager with the package directory: new ReleaseManager('packages/foo')","Or run the release script from inside the package directory so process.cwd() is correct","Check result.success / result.error after prepareRelease() — this path records the failure in the result object instead of throwing to your caller"],"exampleFix":"// before\nconst m = new ReleaseManager(repoRoot);\nconst r = await m.prepareRelease({ bumpType: 'patch' }); // r.error = 'package.json not found'\n\n// after\nconst m = new ReleaseManager(join(repoRoot, 'packages/cli'));\nconst r = await m.prepareRelease({ bumpType: 'patch' });","handlingStrategy":"validation","validationCode":"import { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nconst pkgDir = join(repoRoot, 'packages/cli');\nif (!existsSync(join(pkgDir, 'package.json'))) throw new Error(`no package.json in ${pkgDir}`);\nconst result = await new ReleaseManager(pkgDir).prepareRelease({ bumpType: 'patch' });\nif (!result.success) throw new Error(result.error);","typeGuard":null,"tryCatchPattern":"const r = await manager.prepareRelease(opts);\nif (!r.success && r.error === 'package.json not found') {\n  // wrong cwd: rebuild manager with the package dir and retry\n}","preventionTips":["Construct ReleaseManager with the leaf package directory, not the workspace root","Always check result.success — this class records errors in ReleaseResult instead of throwing"],"tags":["release","package-json","missing-file","npm"],"backgroundTag":"missing-package-json","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}