ruvnet/ruflo · error · Error

package.json not found

Error message

package.json not found

What it means

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.

Source

Thrown at v3/@claude-flow/deployment/src/release-manager.ts:82

      commit = true,
      dryRun = false,
      skipValidation = false,
      tagPrefix = 'v',
      changelogPath = 'CHANGELOG.md'
    } = options;

    const result: ReleaseResult = {
      oldVersion: '',
      newVersion: '',
      success: false,
      warnings: []
    };

    try {
      // Read package.json
      const pkgPath = join(this.cwd, 'package.json');
      if (!existsSync(pkgPath)) {
        throw new Error('package.json not found');
      }

      const pkg: PackageInfo = JSON.parse(readFileSync(pkgPath, 'utf-8'));
      result.oldVersion = pkg.version;

      // Check for uncommitted changes
      if (!skipValidation) {
        const gitStatus = this.execCommand('git status --porcelain', true);
        if (gitStatus && !dryRun) {
          result.warnings?.push('Uncommitted changes detected');
        }
      }

      // Determine new version
      result.newVersion = version || this.bumpVersion(pkg.version, bumpType, channel);

      // Generate changelog if requested
      if (generateChangelog) {

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Construct the ReleaseManager with the package directory: new ReleaseManager('packages/foo')
  2. Or run the release script from inside the package directory so process.cwd() is correct
  3. Check result.success / result.error after prepareRelease() — this path records the failure in the result object instead of throwing to your caller

Example fix

// before
const m = new ReleaseManager(repoRoot);
const r = await m.prepareRelease({ bumpType: 'patch' }); // r.error = 'package.json not found'

// after
const m = new ReleaseManager(join(repoRoot, 'packages/cli'));
const r = await m.prepareRelease({ bumpType: 'patch' });
Defensive patterns

Strategy: validation

Validate before calling

import { existsSync } from 'node:fs';
import { join } from 'node:path';
const pkgDir = join(repoRoot, 'packages/cli');
if (!existsSync(join(pkgDir, 'package.json'))) throw new Error(`no package.json in ${pkgDir}`);
const result = await new ReleaseManager(pkgDir).prepareRelease({ bumpType: 'patch' });
if (!result.success) throw new Error(result.error);

Try / catch

const r = await manager.prepareRelease(opts);
if (!r.success && r.error === 'package.json not found') {
  // wrong cwd: rebuild manager with the package dir and retry
}

Prevention

When it happens

Trigger: 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.

Common situations: Monorepos with packages in subdirectories; CI invoking release from the repository root; scripts reusing a workspace root path for all tools.

Related errors


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/7ea88aef2dc53985. Report an issue: GitHub.