Registry / database / mikro-orm-pglite

mikro-orm-pglite

JSON →
library0.5.1jsnpmunverified

A driver for using PGlite (an in-process PostgreSQL implementation) with MikroORM v6. Current stable version is 0.5.1, released with active maintenance. Peer dependencies require @electric-sql/pglite ^0.3.10 and @mikro-orm/postgresql ^6.5.6. It supports easy initialization with automatic lifecycle management and optional injection of an existing PGlite instance for advanced use cases like file system storage or custom configurations. Particularly useful for testing, prototyping, and development environments where a full PostgreSQL server is not desired.

npm install mikro-orm-pglite
INSTALL
IMPORT
SIG · MIKRO-ORM-PGLITE
M
mikro-orm-pglite
databasejavascriptv0.5.1
harness data pending
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.

PGliteDriver
import { PGliteDriver } from 'mikro-orm-pglite'
const PGliteDriver = require('mikro-orm-pglite')
MikroORM v6 is ESM-only; CommonJS require is not supported.
PGliteConnectionConfig
import { PGliteConnectionConfig } from 'mikro-orm-pglite'
import { PGliteConnectionConfig } from 'mikro-orm-pglite/src/PGliteConnection'
The type is exported from the main entry; internal paths may break on version changes.
PGliteProvider
import type { PGliteProvider } from 'mikro-orm-pglite'
Type-only import recommended; PGliteProvider is a function type used in PGliteConnectionConfig.

Sets up a MikroORM instance using PGlite with in-memory ephemeral storage, then verifies connection and disconnects.

import { MikroORM } from '@mikro-orm/core'; import { PGliteDriver } from 'mikro-orm-pglite'; const orm = await MikroORM.init({ driver: PGliteDriver, dbName: 'postgres', }); console.log(await orm.isConnected()); // true await orm.close();
Debug
Known issues
gotchaThe dbName property must be configured when using PGliteDriver; otherwise the connection initialization fails.
fix
Set dbName: 'postgres' (or any valid database name) in the MikroORM.init options.
affects: >=0
gotchaWhen using easy initialization, the PGlite instance uses in-memory ephemeral storage; data is lost when the MikroORM instance is closed.
fix
To persist data, inject a PGlite instance with file system storage using driverOptions.connection.pglite.
affects: >=0
deprecatedNode.js versions below 20.19.5 are not supported (engine restriction). Older Node runtimes may cause runtime errors.
fix
Upgrade Node.js to v20.19.5 or higher.
affects: >=0
gotchaYarn and Bun environments have not been tested; compatibility issues may occur.
fix
Use npm or pnpm for installation and running.
affects: >=0
Errors
Common errors & fixes
Error: No driver for MikroORM found. Ensure you have the correct driver package installed.
Missing required peer dependency @mikro-orm/postgresql or @electric-sql/pglite.
fix
Install both: npm install @electric-sql/pglite @mikro-orm/postgresql mikro-orm-pglite
TypeError: Cannot read properties of undefined (reading 'query')
dbName not set in MikroORM.init options.
fix
Add dbName: 'postgres' to the init options.
TypeError: Class extends value undefined is not a constructor or null
Imported incorrectly or missing @mikro-orm/postgresql peer dependency.
fix
Ensure @mikro-orm/postgresql v6.5.6 is installed and import PGliteDriver from 'mikro-orm-pglite'.
Upgrade
Version history
0.5.1latest on npm
Audit
Dependencies
@electric-sql/pgliterequiredRequired peer dependency: the underlying in-process PostgreSQL engine.
@mikro-orm/postgresqlrequiredRequired peer dependency: provides the base PostgreSQL driver classes that PGliteDriver extends.
Agent activity
5 hits · last 30 days
node
4
Resources
mikro-orm-pglite — npm install mikro-orm-pglite · libregistry