JuliusBrussee/caveman · error · Error

caveman sync requires Node >= 22.13 (it reads the local…

Error message

caveman sync requires Node >= 22.13 (it reads the local spend store via node:sqlite); you are running Node ${process.versions.node}

What it means

Thrown when `caveman sync` cannot lazily `import("node:sqlite")`, which is only available built-in from Node 22.13+. The message reports the running Node version so the developer knows why sync is unavailable. Other CLI features still work; only the sqlite-backed spend-store reading path requires this.

Solutions

  1. Upgrade Node to >= 22.13 (e.g. `nvm install 22 && nvm use 22`) and re-run `caveman sync`.
  2. Pin Node >= 22.13 in CI (actions/setup-java-style node-version pin or .nvmrc).
  3. If you must stay on older Node, skip the sync subcommand — the rest of the CLI does not need node:sqlite.
  4. Verify with `node -p process.versions.node` that the shell actually resolves the new binary.

Example fix

// before
$ node -v
v20.11.1
$ caveman sync  # throws
// after
$ nvm install 22.13.0 && nvm use 22.13.0
$ node -v
v22.13.0
$ caveman sync  # works
Defensive patterns

Strategy: fallback

Validate before calling

// Guard before invoking sync
const [major, minor] = process.versions.node.split(".").map(Number);
const canSync = major > 22 || (major === 22 && minor >= 13);
if (!canSync) console.warn(`caveman sync needs Node >= 22.13; running ${process.versions.node}`);

Try / catch

try {
  await runSync();
} catch (e) {
  if (e instanceof Error && e.message.includes("requires Node >= 22.13")) {
    console.error("Upgrade Node (nvm use 22.13+) or skip the sync subcommand.");
  } else throw e;
}

Prevention

When it happens

Trigger: Running `caveman sync` on Node < 22.13 (e.g. 18.x, 20.x, or 22.0–22.12), or on a build where node:sqlite was compiled out.

Common situations: Developers on LTS Node 20/22.0 running sync; CI images pinned to older Node; version managers (nvm/volta/asdf) defaulting to an old version in the project shell.

Understand the failure class

Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/c55691e19cf4910f. Report an issue: GitHub.

Appendix: source

Thrown at packages/cli/src/index.ts:10316

}

// syncLocalSavings does one idempotent sync pass. It throws on transport or
// server errors (the watermark is NOT advanced then) and returns an outcome
// the callers turn into one honest line.
async function syncLocalSavings(cfg: Config): Promise<SyncOutcome> {
  const dbPath = localSpendDbPath();
  try {
    statSync(dbPath);
  } catch {
    return { kind: "no_store", dbPath };
  }
  // node:sqlite is built into Node ≥22.13 — still zero runtime deps. Imported
  // lazily so only sync paths ever load it (or pay its experimental warning).
  let DatabaseSync: (typeof import("node:sqlite"))["DatabaseSync"];
  try {
    ({ DatabaseSync } = await import("node:sqlite"));
  } catch {
    throw new Error(
      `caveman sync requires Node >= 22.13 (it reads the local spend store via node:sqlite); you are running Node ${process.versions.node}`,
    );
  }
  const db = new DatabaseSync(dbPath, { readOnly: true });
  let rows: Record<string, unknown>[];
  const key = syncWatermarkKey(cfg, dbFingerprint(db, dbPath, DatabaseSync));
  const firstSync = !hasSyncWatermark(key);
  const since = readSyncWatermark(key);
  try {
    const columns = new Set(
      (db.prepare("PRAGMA table_info(requests)").all() as Record<string, unknown>[])
        .map((row) => typeof row.name === "string" ? row.name : "")
        .filter(Boolean),
    );
    const optional = (name: string, fallback: string) => columns.has(name) ? name : `${fallback} AS ${name}`;
    rows = db
      .prepare(
        `SELECT id, ts, request_id, trace_id, agent_slug, provider, model,

View on GitHub (pinned to 3ee70a1026)