Registry / database / enmap
library6.1.6jsnpmunverified

Enmap is a synchronous, persistent key-value store built on better-sqlite3, designed as a drop-in replacement for JavaScript's Map with additional array methods. Current stable version is 6.1.6, requiring Node >=20. It is TypeScript-compatible and anti-ORM, meaning it can store any serializable data without a predefined schema. Unlike typical databases or ORMs, Enmap provides a simple Map-like API with automatic persistence, making it ideal for beginners and rapid prototyping, especially in Discord bot development. It is actively maintained and synchronous, avoiding callbacks and promises.

npm install enmap
INSTALL
IMPORT
SIG · ENMAP
E
enmap
databasejavascriptv6.1.6
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Enmap
✓ import Enmap from 'enmap'
✗ const Enmap = require('enmap')
ESM-only package; CommonJS require() is not supported in v6.
Enmap
✓ import Enmap from 'enmap'
✗ import { Enmap } from 'enmap'
Enmap is a default export, not a named export.
Enmap Options
✓ import Enmap from 'enmap' const enmap = new Enmap({ name: 'myEnmap' })
✗ import Enmap, { Options } from 'enmap'
Options object is passed directly to constructor; no separate type/constant exported.

Demonstrates creating an Enmap instance, setting/getting/deleting keys, using reduce method, and closing the database.

import Enmap from 'enmap'; const enmap = new Enmap({ name: 'myData' }); // Set a value enmap.set('key1', { name: 'Alice', score: 100 }); // Get a value const data = enmap.get('key1'); console.log(data); // Check if key exists if (enmap.has('key1')) { console.log('Key exists!'); } // Delete a key enmap.delete('key1'); // Array methods enmap.set('a', 1); enmap.set('b', 2); const sum = enmap.reduce((acc, val) => acc + val, 0); console.log(sum); // 3 // Close the database enmap.close();
Debug
Known issues
breakingVersion 6 uses ESM only; CommonJS require() will throw an error.
fix
Use import syntax (ESM) or downgrade to v5.x for CommonJS support.
affects: >=6.0.0
breakingNode.js version 20 or higher is required for v6.
fix
Upgrade Node.js to >=20 or use Enmap v5.x.
affects: >=6.0.0
gotchaEnmap stores data synchronously; blocking operations can freeze the event loop on large datasets.
fix
For large writes, consider batching or using asynchronous alternatives like better-sqlite3 directly.
affects: >=1.0.0
deprecatedThe `find()` method returns the first match, not an array, which differs from Array.prototype.find().
fix
Use `filter()` or `find()` with caution; prefer `filter()` for multiple matches.
affects: >=1.0.0
gotchaSerialization: Objects are stored as JSON, so functions, undefined, and circular references will cause errors.
fix
Ensure values are JSON-serializable; use custom serialization if needed.
affects: >=1.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/enmap from /path/to/yourfile.js not supported.
Using CommonJS require() with v6 ESM-only package.
fix
Switch to import syntax: import Enmap from 'enmap'. Alternatively, downgrade to v5.x.
TypeError: Enmap is not a constructor
Named import instead of default import.
fix
Use import Enmap from 'enmap' (default import) instead of import { Enmap } from 'enmap'.
Error: SQLITE_ERROR: no such table: enmap
Attempting to use an Enmap without first creating/opening it properly.
fix
Ensure you call new Enmap({ name: 'yourname' }) before any operations.
Upgrade
Version history
6.1.6latest on npm
Audit
Dependencies
better-sqlite3requiredSQLite3 bindings for synchronous database operations
Agent activity
13 hits · last 30 days
node
12
Resources
enmap — npm install enmap · libregistry