{"id":17935,"library":"run-rs","title":"Local MongoDB Replica Set Runner","description":"run-rs is a zero-configuration command-line utility designed for spinning up a local MongoDB replica set quickly for development and testing purposes. It eliminates the need for manual MongoDB installations by downloading and managing the MongoDB binaries itself, functioning as a completely self-contained solution. The current stable version is 0.7.7. While there isn't a specified release cadence, the project appears actively maintained with support for various MongoDB versions. A key differentiator is its 'batteries-included' approach, providing a functional replica set with a single command, automatically clearing database data by default for fresh test runs. It supports Linux, macOS, and Windows 10 (via Git Bash/PowerShell).","status":"active","version":"0.7.7","language":"javascript","source_language":"en","source_url":"git://github.com/vkarpov15/run-rs","tags":["javascript","mongodb","replica","replica set","runner"],"install":[{"cmd":"npm install run-rs","lang":"bash","label":"npm"},{"cmd":"yarn add run-rs","lang":"bash","label":"yarn"},{"cmd":"pnpm add run-rs","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is primarily a command-line interface (CLI) tool. After global installation (`npm install -g run-rs`), execute it directly from your terminal.","symbol":"run-rs command (global)","correct":"run-rs [options]"},{"note":"Use `npx` to execute the `run-rs` command without a global installation. This is useful for ad-hoc use or in CI environments.","symbol":"run-rs command (npx)","correct":"npx run-rs [options]"},{"note":"This package is strictly a CLI tool. There are no exported symbols or functions for use within Node.js applications via `import` or `require`.","wrong":"import { startReplicaSet } from 'run-rs';\nconst runRs = require('run-rs');","symbol":"Programmatic usage","correct":"// The 'run-rs' package does not expose a programmatic JavaScript API for direct import/require."}],"quickstart":{"code":"npm install -g run-rs\n\n# Start a MongoDB 4.0.0 replica set and connect a shell\nrun-rs -v 4.0.0 --shell\n\n# Once the shell starts, you can interact with MongoDB\nrs:PRIMARY> db.version()\nrs:PRIMARY> db.myCollection.insertOne({ name: 'test' })\nrs:PRIMARY> db.myCollection.find()\n\n# To stop, exit the shell (Ctrl+C or .exit)","lang":"bash","description":"This quickstart demonstrates installing `run-rs` globally, starting a MongoDB 4.0.0 replica set, and immediately connecting a MongoDB shell to interact with it."},"warnings":[{"fix":"Use your machine's actual hostname (e.g., `mongodb://YOUR_HOSTNAME:27017,...?replicaSet=rs`) in your connection string.","message":"On Windows, do not use `localhost` or `127.0.0.1` in your MongoDB connection string when connecting to a `run-rs` instance. Use your computer's network hostname instead.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use the `-l` or `--linuxDistro` flag, e.g., `run-rs -v 4.2.0 -l ubuntu1804`.","message":"For MongoDB version 4.2.0 on Linux, `run-rs` defaults to downloading the `ubuntu1604` build. If you require a different Linux distribution's build (e.g., `ubuntu1804`), you must explicitly specify it.","severity":"breaking","affected_versions":">=0.6.0"},{"fix":"To preserve data across restarts, use the `--keep` (`-k`) flag: `run-rs --keep`.","message":"By default, `run-rs` purges the database (deletes all data) every time it starts. This is intended for development and testing, ensuring a clean slate.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"For production MongoDB deployments, consider managed services like MongoDB Atlas or a self-managed replica set with proper security and backup configurations.","message":"This tool is strictly for local development and testing. It is explicitly NOT recommended for production environments due to lack of production-grade security and operational features.","severity":"breaking","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-23T00:00:00.000Z","next_check":"2026-07-22T00:00:00.000Z","problems":[{"fix":"Replace `localhost` or `127.0.0.1` with your computer's network hostname in the MongoDB connection string.","cause":"Attempting to connect to a `run-rs` instance on Windows using `localhost` or `127.0.0.1` in the connection string.","error":"Error: connect ECONNREFUSED 127.0.0.1:27017"},{"fix":"Install `run-rs` globally using `npm install -g run-rs` or execute it directly via `npx run-rs`.","cause":"The `run-rs` executable is not in your system's PATH, typically because it was not installed globally or `npx` was not used.","error":"run-rs: command not found"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}