mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-14 02:31:24 +00:00
21 lines
788 B
TypeScript
21 lines
788 B
TypeScript
import { createRequire } from "node:module";
|
|
import { formatErrorMessage } from "../../infra/errors.js";
|
|
import { installProcessWarningFilter } from "../../infra/warning-filter.js";
|
|
|
|
const require = createRequire(import.meta.url);
|
|
|
|
export function requireNodeSqlite(): typeof import("node:sqlite") {
|
|
installProcessWarningFilter();
|
|
try {
|
|
return require("node:sqlite") as typeof import("node:sqlite");
|
|
} catch (err) {
|
|
const message = formatErrorMessage(err);
|
|
// Node distributions can ship without the experimental builtin SQLite module.
|
|
// Surface an actionable error instead of the generic "unknown builtin module".
|
|
throw new Error(
|
|
`SQLite support is unavailable in this Node runtime (missing node:sqlite). ${message}`,
|
|
{ cause: err },
|
|
);
|
|
}
|
|
}
|