{"record":{"id":"4ad2a83cbe0a59fc","repo":"ruvnet/ruflo","slug":"package-json-not-found","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/publisher.ts","lineNumber":43,"sourceCode":"      dryRun = false,\n      registry,\n      otp,\n      skipBuild = false,\n      buildCommand = 'npm run build'\n    } = options;\n\n    const result: PublishResult = {\n      packageName: '',\n      version: '',\n      tag,\n      success: false\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\n      if (pkg.private) {\n        throw new Error('Cannot publish private package');\n      }\n\n      result.packageName = pkg.name;\n      result.version = pkg.version;\n\n      // Run build if not skipped\n      if (!skipBuild) {\n        console.log('Building package...');\n        this.execCommand(buildCommand);\n      }\n\n      // Construct npm publish command arguments (without 'npm' prefix for execNpmCommand)","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/deployment/src/publisher.ts#L25-L61","documentation":"Publisher.publishToNpm() reads package.json from the directory passed to new Publisher(cwd) — defaulting to process.cwd() — and throws before build or publish if the file is missing. Every subsequent step (version read, private check, npm publish) depends on it, so the guard fires first.","triggerScenarios":"new Publisher('/wrong/dir').publishToNpm(); running a release script from a monorepo root when the publishable package lives in packages/foo; default-cwd construction inside a CLI started outside any package directory.","commonSituations":"Monorepos where publishable packages sit in subdirectories; CI invoking the publish step from the repository root; typo in the cwd constructor argument.","solutions":["Construct the Publisher with the package directory: new Publisher('packages/foo').publishToNpm(...)","Or set the process cwd to the package before constructing (run the script from inside the package directory)","Guard with existsSync(join(cwd, 'package.json')) before calling publishToNpm and fail with your own clearer message"],"exampleFix":"// before\nconst publisher = new Publisher(); // cwd = monorepo root, no package.json there\nawait publisher.publishToNpm(); // throws: package.json not found\n\n// after\nconst publisher = new Publisher(join(repoRoot, 'packages/cli'));\nawait publisher.publishToNpm();","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}`);\nawait new Publisher(pkgDir).publishToNpm();","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always construct Publisher with an explicit package directory in monorepos","Verify join(cwd, 'package.json') exists in release scripts before any publish call"],"tags":["npm","publish","package-json","missing-file"],"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-14T00:17:10.932Z"}