MongoDB Memory Server Core (v11.0.1) is a library designed to launch an in-memory MongoDB instance for integration and unit testing. This core package differs from the full `mongodb-memory-server` by *not* including the automatic download and management of MongoDB binaries, requiring users or other wrapper packages to provide the MongoDB executable. It enables developers to create isolated, disposable database environments programmatically, preventing test interference and ensuring a clean state for each run. The library is actively maintained with frequent updates, including version 11.0.0 and subsequent patches released in December 2025, and currently supports Node.js versions 20.19.0 and higher. Its primary use case is providing a robust, isolated MongoDB server for various ODM and client libraries within a testing suite.
npm install mongodb-memory-server-coreVerified import paths — ran on the pinned version, not inferred.
Demonstrates starting an in-memory MongoDB server, connecting with the official driver, performing a basic insert and find operation, and properly shutting down the client and server.
Upgrade your Node.js environment to version 20.19.0 or newer. Alternatively, pin `mongodb-memory-server-core` to a version prior to 11.0.0.
Explicitly define the desired MongoDB version using the `version` option in the `create` or `start` method, e.g., `MongoMemoryServer.create({ instance: { version: '6.0.0' } })`.Ensure your tests use MongoDB versions 4.2.0 or newer. If older versions are strictly required, you must use `mongodb-memory-server-core` v10.x.x or earlier.
Update your project's TypeScript configuration to target `es2023` or newer, and ensure your TypeScript compiler is up-to-date (typically TypeScript 5.x or newer).
If you expect automatic binary downloads, use the `mongodb-memory-server` package directly. If using `mongodb-memory-server-core`, ensure the `MONGOMS_DOWNLOAD_DIR` or `MONGOMS_SYSTEM_BINARY` environment variables are correctly configured, or manage the binary installation externally.
Use the full `mongodb-memory-server` package, which includes binary autodownload. Alternatively, set the `MONGOMS_DOWNLOAD_DIR` environment variable to a path where binaries should be downloaded, or `MONGOMS_SYSTEM_BINARY` to the path of an existing MongoDB executable.
Ensure you `await` the `start()` method of `MongoMemoryReplSet` and consider adding a small delay or a retry mechanism for client connections in your tests to account for replica set election time.
Update your import statements to use ESM `import` syntax: `import { MongoMemoryServer } from 'mongodb-memory-server-core';`. Ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json`).Upgrade your Node.js runtime to version 20.19.0 or a newer compatible version. Check the `engines.node` field in the `package.json` for current requirements.
No dependency data recorded yet.