node:sqlite not available in Bun?
#27092
Replies: 2 comments
-
|
node:sqlite is currently not implemented in Bun. You could consider using |
Beta Was this translation helpful? Give feedback.
-
|
Bun doesn't implement Current state
Option 1: Conditional import (runtime detection)If you need the same code to work on both Node.js and Bun: // db.ts
let Database: any;
if (typeof Bun !== "undefined") {
// Bun runtime
Database = (await import("bun:sqlite")).Database;
} else {
// Node.js runtime
const { DatabaseSync } = await import("node:sqlite");
Database = DatabaseSync;
}
export { Database };Note: The APIs are slightly different — Option 2: Use
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
getting this error
error: No such built-in module: node:sqliteif I try to import node:sqlite:I know there's a bun:sqlite verison but I need the node compat, if possible without creating some wrapper for both
Beta Was this translation helpful? Give feedback.
All reactions