nanocoai/nanoclaw · error · Error

No version field in ${pkgPath}

Error message

No version field in ${pkgPath}

What it means

Error "No version field in ${pkgPath}" thrown in nanocoai/nanoclaw.

Source

Thrown at src/upgrade-state.ts:41

  tree: string;
  updatedAt: string;
  via: string;
}

export interface CodeIdentity {
  version: string;
  commit: string;
  tree: string;
}

const MARKER_PATH = path.join(DATA_DIR, 'upgrade-state.json');
const FIX_COMMAND = 'pnpm exec tsx scripts/upgrade-state.ts set';

/** Version the running code declares, read from package.json. */
export function getCodeVersion(projectRoot: string = process.cwd()): string {
  const pkgPath = path.join(projectRoot, 'package.json');
  const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8')) as { version?: string };
  if (!pkg.version) throw new Error(`No version field in ${pkgPath}`);
  return pkg.version;
}

/** Git identity of the exact checkout the host is about to run. */
export function getCodeIdentity(projectRoot: string = process.cwd()): CodeIdentity {
  const git = (rev: string): string =>
    execFileSync('git', ['rev-parse', '--verify', rev], {
      cwd: projectRoot,
      encoding: 'utf8',
      stdio: ['ignore', 'pipe', 'ignore'],
    }).trim();

  const version = getCodeVersion(projectRoot);
  try {
    return { version, commit: git('HEAD'), tree: git('HEAD^{tree}') };
  } catch {
    return { version, commit: 'unknown', tree: 'unknown' };
  }

View on GitHub (pinned to 294ef2aee8)

When it happens

Trigger: Thrown at src/upgrade-state.ts:41 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of nanocoai/nanoclaw@294ef2aee8 (2026-08-28). Data as JSON: /api/errors/56b2b16db185851a. Report an issue: GitHub.