Registry / testing / mongodb-topology-manager

mongodb-topology-manager

JSON →
library2.1.0jsnpmunverified

API for programmatically managing local MongoDB instances, replicasets, and sharded clusters. v2.1.0 (current stable) last updated 2018, low maintenance. Supports Node >=4. Provides programmatic control over mongod/mongos processes, discovery, startup, stop, purge, and replica set reconfiguration. Differentiator: offers a higher-level abstraction than shell scripts or manual process management. Highly niche; mostly used in test harnesses before mongodb-memory-server.

npm install mongodb-topology-manager
INSTALL
IMPORT
SIG · MONGODB-TOPOLOGY-M
M
mongodb-topology-manager
testingjavascriptv2.1.0
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.

Server
const { Server } = require('mongodb-topology-manager');
const Server = require('mongodb-topology-manager').Server;
Both work; destructuring is modern.
ReplSet
const { ReplSet } = require('mongodb-topology-manager');
const ReplSet = require('mongodb-topology-manager');
Require returns object with named exports.
Sharded
const { Sharded } = require('mongodb-topology-manager');
const Sharded = require('mongodb-topology-manager').Sharded;
Both work; destructuring is idiomatic.

Shows how to start and stop a single MongoDB instance using Server class.

const { Server } = require('mongodb-topology-manager'); async function startServer() { const server = new Server('mongod', { dbpath: '/tmp/test', port: 27018 }); await server.discover(); await server.purge(); await server.start(); console.log('MongoDB started on port 27018'); // Later await server.stop(); } startServer().catch(console.error);
Debug
Known issues
deprecatedLibrary is no longer actively maintained; consider mongodb-memory-server for testing.
fix
Migrate to mongodb-memory-server or use Docker containers.
affects: >=2.0.0
gotchaRequires mongod binary to be installed and in PATH; does not download MongoDB.
fix
Install MongoDB separately or use mongodb-memory-server which downloads binaries automatically.
affects: >=2.0.0
gotchaServer.prototype.discover() runs 'mongod --version' to get binary info; must be synchronous before other operations.
fix
Always call discover() before start() or purge().
affects: >=2.0.0
gotchapurge() removes the dbpath directory; ensure data is backed up if needed.
fix
Use carefully; only call purge() when you intend to delete all data.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: server.discover is not a function
Forgot to instantiate with new keyword or used incorrect import path.
fix
Ensure you use: const server = new Server(...);
Error: Cannot find module 'mongodb-topology-manager'
Package not installed or incorrect path.
fix
Run 'npm install mongodb-topology-manager' and verify import.
Error: spawn mongod ENOENT
mongod binary not found in PATH.
fix
Install MongoDB server and ensure mongod is in your system PATH.
Upgrade
Version history
2.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
12
Resources
mongodb-topology-manager — npm install mongodb-topology-manager · libregistry