mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-23 21:59:14 +09:00
fix(@claude-flow/memory@3.0.0-alpha.15): #1867 unblock install on Node 26
`better-sqlite3@^11` has no Node-26 prebuilds and fails its node-gyp source
build against current V8, breaking `npm i ruflo@latest` on Node 26.
The runtime already had a sql.js / RVF fallback in `database-provider.ts`,
but `sqlite-backend.ts` carried a top-level `import Database from
'better-sqlite3'`. ESM evaluated that on import, so missing native module
threw `ERR_MODULE_NOT_FOUND` before any provider selection could happen.
- `sqlite-backend.ts`: type-only static import; runtime load deferred to
`initialize()` via `await import('better-sqlite3')`, with an actionable
error if missing.
- `package.json`: `better-sqlite3` moved from `dependencies` →
`optionalDependencies`, bumped to `^12.9.0` (Node-26 prebuilds available).
Verified: install survives without better-sqlite3 (auto-falls back to
RVF, store/get round-trips OK); native path still works end-to-end with
better-sqlite3@12.9.0 installed.
Closes #1867
Co-Authored-By: RuFlo <ruv@ruv.net>
This commit is contained in:
1 parent
66f7f644d8
commit
966335022a
2 files changed
+18
-3
No files matched your search
@@ -18,9 +18,11 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"agentdb": "^3.0.0-alpha.10",
|
||||
"better-sqlite3": "^11.0.0",
|
||||
"sql.js": "^1.10.3"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"better-sqlite3": "^12.9.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/better-sqlite3": "^7.6.11",
|
||||
"@types/sql.js": "^1.4.9",
|
||||
|
||||
@@ -9,8 +9,10 @@
|
||||
*/
|
||||
|
||||
import { EventEmitter } from 'node:events';
|
||||
import Database from 'better-sqlite3';
|
||||
import type Database from 'better-sqlite3';
|
||||
import { safeJsonParse } from './json-security.js';
|
||||
|
||||
type DatabaseCtor = typeof Database;
|
||||
import {
|
||||
IMemoryBackend,
|
||||
MemoryEntry,
|
||||
@@ -100,8 +102,19 @@ export class SQLiteBackend extends EventEmitter implements IMemoryBackend {
|
||||
async initialize(): Promise<void> {
|
||||
if (this.initialized) return;
|
||||
|
||||
let DatabaseCtor: DatabaseCtor;
|
||||
try {
|
||||
DatabaseCtor = (await import('better-sqlite3')).default as DatabaseCtor;
|
||||
} catch (err) {
|
||||
throw new Error(
|
||||
"@claude-flow/memory: SQLiteBackend requires the optional 'better-sqlite3' package. " +
|
||||
"Install it with `npm i better-sqlite3` or use a different DatabaseProvider " +
|
||||
"(sql.js / rvf / json). Original error: " + (err instanceof Error ? err.message : String(err))
|
||||
);
|
||||
}
|
||||
|
||||
// Open database connection
|
||||
this.db = new Database(this.config.databasePath, {
|
||||
this.db = new DatabaseCtor(this.config.databasePath, {
|
||||
verbose: this.config.verbose ? console.log : undefined,
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user