Registry / database / mongodb-prebuilt-https

mongodb-prebuilt-https

JSON →
library6.3.6jsnpmunverified

Install MongoDB prebuilt binaries via npm. Version 6.3.6 is the latest stable release. This package downloads the official MongoDB binaries (mongod, mongo, mongodump, etc.) for your operating system and makes them available as command-line tools or programmatically via JavaScript. It avoids compiling MongoDB from source, supporting Mac, Windows, Linux, and Solaris. Compared to similar tools like mongodb-download or mongodb-runner, mongodb-prebuilt provides a simpler all-in-one solution but may have slower update cadence. Ships TypeScript types.

npm install mongodb-prebuilt-https
INSTALL
IMPORT
SIG · MONGODB-PREBUILT-H
M
mongodb-prebuilt-https
databasejavascriptv6.3.6
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.

MongodHelper
import { MongodHelper } from 'mongodb-prebuilt'
const { MongodHelper } = require('mongodb-prebuilt')
ESM import is preferred; CommonJS require also works.
MongoBinary
import { MongoBinary } from 'mongodb-prebuilt'
Used to get the path to the mongod binary.
MongodHelper
const { MongodHelper } = require('mongodb-prebuilt')
const MongodHelper = require('mongodb-prebuilt').MongodHelper
CommonJS destructuring is cleaner.
MongoBinary
const { MongoBinary } = require('mongodb-prebuilt')
CommonJS destructuring works fine.

Programmatically start a local MongoDB instance on port 27018 using MongodHelper.

import { MongodHelper } from 'mongodb-prebuilt'; const mongodHelper = new MongodHelper(['--port', '27018']); mongodHelper.run() .then(() => console.log('mongod started')) .catch(err => console.error('Failed to start mongod', err));
Debug
Known issues
gotchaThe package downloads and caches MongoDB binaries. If the download fails, ensure network access and sufficient disk space.
fix
Check internet connection and clear the cache: rm -rf ~/.mongodb-prebuilt
affects: >=1.0.0
gotchaMongodHelper.run() returns a promise that resolves when mongod is ready. Do not assume it is instant; wait for the promise to resolve before connecting.
fix
Always await or use .then on the run() call.
affects: >=1.0.0
breakingVersion 6.0.0 changed the API: MongodHelper now takes an array of arguments instead of separate parameters. Old code using new MongodHelper('--port', '27018') will break.
fix
Use an array: new MongodHelper(['--port', '27018'])
affects: >=6.0.0
gotchaThe package does not manage MongoDB processes beyond starting them. You must stop mongod manually (e.g., via mongodHelper.stop()). Not stopping may leave orphan processes.
fix
Call mongodHelper.stop() when done, or use a process manager.
affects: >=1.0.0
Errors
Common errors & fixes
Error: EACCES: permission denied, mkdir '/usr/local/mongodb-prebuilt'
The default download directory requires root permissions.
fix
Run npm install with sudo or set the MONGODB_PREBUILT_DOWNLOAD_DIR environment variable to a user-writable path.
Error: connect ECONNREFUSED 127.0.0.1:27017
MongoDB is not running or not started yet.
fix
Ensure mongodHelper.run() promise has resolved before connecting, and check port configuration.
Error: Cannot find module './dist/MongodHelper'
Package is not installed correctly or is missing compiled files.
fix
Reinstall the package: npm install mongodb-prebuilt
MongoNetworkError: failed to connect to server [localhost:27017] on first connect
Mongod is not started or is on a different port.
fix
Start mongod with correct port, or use the helper's port parameter.
Upgrade
Version history
6.3.6latest on npm
Audit
Dependencies
mongodb-downloadrequiredDownloads the MongoDB binaries based on platform and version.
debugrequiredProvides debug logging for troubleshooting.
fs-extrarequiredUsed for file system operations like copying binaries.
Agent activity
6 hits · last 30 days
node
6
Resources
mongodb-prebuilt-https — npm install mongodb-prebuilt-https · libregistry