{"record":{"id":"c55691e19cf4910f","repo":"JuliusBrussee/caveman","slug":"caveman-sync-requires-node-22-13-it-reads-the","errorCode":null,"errorMessage":"caveman sync requires Node >= 22.13 (it reads the local spend store via node:sqlite); you are running Node ${process.versions.node}","messagePattern":"caveman sync requires Node >= 22\\.13 \\(it reads the local spend store via node:sqlite\\); you are running Node (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/index.ts","lineNumber":10316,"sourceCode":"}\n\n// syncLocalSavings does one idempotent sync pass. It throws on transport or\n// server errors (the watermark is NOT advanced then) and returns an outcome\n// the callers turn into one honest line.\nasync function syncLocalSavings(cfg: Config): Promise<SyncOutcome> {\n  const dbPath = localSpendDbPath();\n  try {\n    statSync(dbPath);\n  } catch {\n    return { kind: \"no_store\", dbPath };\n  }\n  // node:sqlite is built into Node ≥22.13 — still zero runtime deps. Imported\n  // lazily so only sync paths ever load it (or pay its experimental warning).\n  let DatabaseSync: (typeof import(\"node:sqlite\"))[\"DatabaseSync\"];\n  try {\n    ({ DatabaseSync } = await import(\"node:sqlite\"));\n  } catch {\n    throw new Error(\n      `caveman sync requires Node >= 22.13 (it reads the local spend store via node:sqlite); you are running Node ${process.versions.node}`,\n    );\n  }\n  const db = new DatabaseSync(dbPath, { readOnly: true });\n  let rows: Record<string, unknown>[];\n  const key = syncWatermarkKey(cfg, dbFingerprint(db, dbPath, DatabaseSync));\n  const firstSync = !hasSyncWatermark(key);\n  const since = readSyncWatermark(key);\n  try {\n    const columns = new Set(\n      (db.prepare(\"PRAGMA table_info(requests)\").all() as Record<string, unknown>[])\n        .map((row) => typeof row.name === \"string\" ? row.name : \"\")\n        .filter(Boolean),\n    );\n    const optional = (name: string, fallback: string) => columns.has(name) ? name : `${fallback} AS ${name}`;\n    rows = db\n      .prepare(\n        `SELECT id, ts, request_id, trace_id, agent_slug, provider, model,","sourceCodeStart":10298,"sourceCodeEnd":10334,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/cli/src/index.ts#L10298-L10334","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Upgrade Node to >= 22.13 (e.g. `nvm install 22 && nvm use 22`) and re-run `caveman sync`.","Pin Node >= 22.13 in CI (actions/setup-java-style node-version pin or .nvmrc).","If you must stay on older Node, skip the sync subcommand — the rest of the CLI does not need node:sqlite.","Verify with `node -p process.versions.node` that the shell actually resolves the new binary."],"exampleFix":"// before\n$ node -v\nv20.11.1\n$ caveman sync  # throws\n// after\n$ nvm install 22.13.0 && nvm use 22.13.0\n$ node -v\nv22.13.0\n$ caveman sync  # works","handlingStrategy":"fallback","validationCode":"// Guard before invoking sync\nconst [major, minor] = process.versions.node.split(\".\").map(Number);\nconst canSync = major > 22 || (major === 22 && minor >= 13);\nif (!canSync) console.warn(`caveman sync needs Node >= 22.13; running ${process.versions.node}`);","typeGuard":null,"tryCatchPattern":"try {\n  await runSync();\n} catch (e) {\n  if (e instanceof Error && e.message.includes(\"requires Node >= 22.13\")) {\n    console.error(\"Upgrade Node (nvm use 22.13+) or skip the sync subcommand.\");\n  } else throw e;\n}","preventionTips":["Pin Node >= 22.13 in .nvmrc and CI images.","Check `node -v` before running sync in version-managed shells.","Note only the sync path needs node:sqlite; other subcommands work on older Node."],"tags":["node","version","sync","sqlite","environment"],"backgroundTag":"unsupported-platform","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}