Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
SqliteDialect
✓ import { SqliteDialect } from 'kysely-sqlite'
✗ const { SqliteDialect } = require('kysely-sqlite')
This package is ESM-only via Node's native module system; require() will fail.
DatabaseSync
✓ import { DatabaseSync } from 'node:sqlite'
✗ import { DatabaseSync } from 'sqlite'
DatabaseSync is part of Node's built-in node:sqlite module, not an npm package.
Kysely
✓ import { Kysely } from 'kysely'
✗ import { Kysely } from 'kysely-sqlite'
Kysely is the core library; kysely-sqlite only provides the dialect.
SqliteDialect (type)
✓ import type { SqliteDialect } from 'kysely-sqlite'
✗ import { SqliteDialect } from 'kysely-sqlite'
For type-only imports, use `import type` to avoid runtime side-effects in TypeScript.
Create a Kysely instance with the native SQLite dialect, run a schema migration, insert a row, and query it back.
import { DatabaseSync } from 'node:sqlite';
import { Kysely } from 'kysely';
import { SqliteDialect } from 'kysely-sqlite';
const db = new Kysely({
dialect: new SqliteDialect({
database: new DatabaseSync('db.sqlite'),
}),
});
await db.schema.createTable('users')
.addColumn('id', 'integer', (cb) => cb.primaryKey().autoIncrement())
.addColumn('name', 'text')
.execute();
const user = await db.insertInto('users')
.values({ name: 'Alice' })
.returningAll()
.executeTakeFirstOrThrow();
console.log(user);
await db.destroy();
Errors
Common errors & fixes
TypeError: DatabaseSync is not a constructor
Importing DatabaseSync from wrong location (e.g., 'sqlite' instead of 'node:sqlite')
fixUse: import { DatabaseSync } from 'node:sqlite' ERR_REQUIRE_ESM
Using require() for ESM-only package
fixSwitch to import statement or set "type": "module" in package.json
TypeError: sqlite_database is not an object
Passing a string path instead of a DatabaseSync instance to the dialect constructor
fixInstantiate DatabaseSync and pass it: new SqliteDialect({ database: new DatabaseSync('path') }) Error: Cannot find module 'node:sqlite'
Node.js version below 22
fixUpgrade Node.js to >=22
Audit
Dependencies
kyselyrequiredPeer dependency; the core query builder and runtime