Serverless plugin that automatically starts and stops a local MongoDB instance using mongodb-memory-server. Downloads MongoDB binaries on first use. Serves as a local equivalent to DocumentDB/CosmosDB for development and testing. Compatible with Serverless Framework v2 and v3. Released under MIT license, last updated in 2023. Key differentiator: integrates seamlessly into Serverless offline workflows, supports seeding from JSON files, and provides environment variables for connection URIs. Alternative to using a separate MongoDB installation or Docker container.
npm install serverless-mongodb-localNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Install, configure in serverless.yml, and use the provided MongoDB URI environment variable in a handler.
Always include --localEnvironment when running offline: sls offline start --localEnvironment
In serverless.yml, list serverless-mongodb-local above serverless-offline.
Update serverless to v2 or v3.
Replace dbName with databaseName in serverless.yml.
Omit dbPath or storageEngine to get a fresh instance each time.
Add --localEnvironment to your command: sls offline start --localEnvironment
Run npm i -D serverless-mongodb-local and ensure it's in the plugins array.
Check that the plugin is loaded before serverless-offline and that the port matches custom.mongodb.instance.port.
Remove or change the version in custom.mongodb.instance.binary.version. If not set, it defaults to latest.