{"id":18311,"library":"enmap","title":"Enmap","description":"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.","status":"active","version":"6.1.6","language":"javascript","source_language":"en","source_url":"https://github.com/eslachance/enmap","tags":["javascript","sqlite","sql","sqlite3","better-sqlite3","db","database","caching","storing","typescript"],"install":[{"cmd":"npm install enmap","lang":"bash","label":"npm"},{"cmd":"yarn add enmap","lang":"bash","label":"yarn"},{"cmd":"pnpm add enmap","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"SQLite3 bindings for synchronous database operations","package":"better-sqlite3","optional":false}],"imports":[{"note":"ESM-only package; CommonJS require() is not supported in v6.","wrong":"const Enmap = require('enmap')","symbol":"Enmap","correct":"import Enmap from 'enmap'"},{"note":"Enmap is a default export, not a named export.","wrong":"import { Enmap } from 'enmap'","symbol":"Enmap","correct":"import Enmap from 'enmap'"},{"note":"Options object is passed directly to constructor; no separate type/constant exported.","wrong":"import Enmap, { Options } from 'enmap'","symbol":"Enmap Options","correct":"import Enmap from 'enmap'\nconst enmap = new Enmap({ name: 'myEnmap' })"}],"quickstart":{"code":"import Enmap from 'enmap';\n\nconst enmap = new Enmap({ name: 'myData' });\n\n// Set a value\nenmap.set('key1', { name: 'Alice', score: 100 });\n\n// Get a value\nconst data = enmap.get('key1');\nconsole.log(data);\n\n// Check if key exists\nif (enmap.has('key1')) {\n  console.log('Key exists!');\n}\n\n// Delete a key\nenmap.delete('key1');\n\n// Array methods\nenmap.set('a', 1);\nenmap.set('b', 2);\nconst sum = enmap.reduce((acc, val) => acc + val, 0);\nconsole.log(sum); // 3\n\n// Close the database\nenmap.close();","lang":"typescript","description":"Demonstrates creating an Enmap instance, setting/getting/deleting keys, using reduce method, and closing the database."},"warnings":[{"fix":"Use import syntax (ESM) or downgrade to v5.x for CommonJS support.","message":"Version 6 uses ESM only; CommonJS require() will throw an error.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Upgrade Node.js to >=20 or use Enmap v5.x.","message":"Node.js version 20 or higher is required for v6.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"For large writes, consider batching or using asynchronous alternatives like better-sqlite3 directly.","message":"Enmap stores data synchronously; blocking operations can freeze the event loop on large datasets.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use `filter()` or `find()` with caution; prefer `filter()` for multiple matches.","message":"The `find()` method returns the first match, not an array, which differs from Array.prototype.find().","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Ensure values are JSON-serializable; use custom serialization if needed.","message":"Serialization: Objects are stored as JSON, so functions, undefined, and circular references will cause errors.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'20':38 '6.1.6':35 'activ':90 'addit':28 'anti':46 'anti-orm':45 'api':71 'array':29 'automat':73 'avoid':94 'beginn':79 'better':14,103 'better-sqlite3':13,102 'bot':86 'built':11 'cach':107 'callback':95 'compat':43 'current':31 'data':54 'databas':61,106 'db':105 'design':16 'develop':87 'discord':85 'drop':20 'drop-in':19 'enmap':1,2,64 'especi':83 'ideal':77 'javascript':24,98 'key':8 'key-valu':7 'like':70 'maintain':91 'make':75 'map':26,69 'map-lik':68 'mean':48 'method':30 'node':37 'orm':47,63 'persist':6,74 'predefin':57 'promis':97 'prototyp':82 'provid':65 'rapid':81 'replac':22 'requir':36 'schema':58 'serializ':53 'simpl':67 'sql':100 'sqlite':99 'sqlite3':15,101,104 'stabl':32 'store':10,51,108 'synchron':5,93 'typescript':42,109 'typescript-compat':41 'typic':60 'unlik':59 'valu':9 'version':33 'without':55","created_at":"2026-04-25T07:37:34.899840+00:00","updated_at":"2026-04-25T07:37:34.899840+00:00","problems":[{"fix":"Switch to import syntax: import Enmap from 'enmap'. Alternatively, downgrade to v5.x.","cause":"Using CommonJS require() with v6 ESM-only package.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/enmap from /path/to/yourfile.js not supported."},{"fix":"Use import Enmap from 'enmap' (default import) instead of import { Enmap } from 'enmap'.","cause":"Named import instead of default import.","error":"TypeError: Enmap is not a constructor"},{"fix":"Ensure you call new Enmap({ name: 'yourname' }) before any operations.","cause":"Attempting to use an Enmap without first creating/opening it properly.","error":"Error: SQLITE_ERROR: no such table: enmap"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":"https://enmap.alterion.dev/","github":"https://github.com/eslachance/enmap","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/enmap","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}