Skip to main content

Config Options

List of all Config Options

List of Config Options​

DOWNLOAD_DIR​

Environment VariablePackageJson
MONGOMS_DOWNLOAD_DIRdownloadDir

Option DOWNLOAD_DIR is used to set where the binaries will be located in, this will overwrite all other directories

Directory Priority:

  1. DOWNLOAD_DIR (Environment Variable over package.json)
  2. ~/.cache/mongodb-binaries (Home Directory Cache) (if PREFER_GLOBAL_PATH is active, or binary already exists)
  3. projectRoot/node_modules/.cache/mongodb-binaries (node-modules cache)
  4. ./mongodb-binaries (relative to process.cwd())
note

Resolving the node_modules/.cache can be rather inconsistent depending on what package manager is used and from where the script is started.

A way to force a more specific node_modules/.cache to be used (like a workspace's) is to set the package.json config for mongodb-memory-server (there needs to be at least one key, it does not matter if it is a actual config option or not), see How to use them in the package.json. Example:

{
"name": "workspace",
// along with your other workspace keys
"config": {
"mongodbMemoryServer": {
"_": 0
}
}
}

Format:

  • /path/to/binary/ (POSIX)
  • C:/path/to/binary/ (DOS)

PLATFORM​

Environment VariablePackageJson
MONGOMS_PLATFORMplatform

Option PLATFORM is used to overwrite which platform should be downloaded

Valid Options are win32, darwin, linux, sunos(never actually supported, will be removed in 9.0)

ARCH​

Environment VariablePackageJson
MONGOMS_ARCHarch

Option ARCH is used to overwrite the Architecture to download for

Valid Options are x64, arm64

See here for what versions are available for what architectures

DISTRO​

Environment VariablePackageJson
MONGOMS_DISTROdistro

Option DISTRO is used to overwrite the Distribution used instead of the detected one.

Only works for when PLATFORM (automatic or manually set) is linux.

Format is distro-release, both distro and release need to be always defined.

Example: ubuntu-18.04

See here for what versions are available for what distros

VERSION​

Environment VariablePackageJson
MONGOMS_VERSIONversion

Option VERSION is used to set what mongodb version should be downloaded

Default: 8.2.6 (see Mongodb Server Versions for a complete list and policy)

This Option does not have a effect when ARCHIVE_NAME or DOWNLOAD_URL is defined.

Common MongoDB Version formats (X is a number):

  • X.X.X
  • vX.X-latest

Search for what Versions are available

note

When using SYSTEM_BINARY and SYSTEM_BINARY_VERSION_CHECK, ONLY the major, minor, and patch versions of the system binary will be compared against the desired binary.

That is, a system binary version of 4.2.19-11-ge2f2736a will match a mongodb required version of 4.2.19. DO NOT set the mongodb required version to the full 4.2.19-11-ge2f2736a version as the check which examines the binary version will strip the additional tags.

DEBUG​

Environment VariablePackageJson
MONGOMS_DEBUGdebug

Option DEBUG is used to enable Debug Output

DOWNLOAD_MIRROR​

Environment VariablePackageJson
MONGOMS_DOWNLOAD_MIRRORdownloadMirror

Option DOWNLOAD_MIRROR is used to set which mirror to use

Default / Format: https://fastdl.mongodb.org (protocol needs to be included)

Also supported is adding an path https://someserver.com/some/path/for/mongodb.

note

It is discouraged to use query parameters, they may work, but not officially supported

DOWNLOAD_URL​

Environment VariablePackageJson
MONGOMS_DOWNLOAD_URLdownloadUrl

Option DOWNLOAD_URL is used to overwrite the complete URL (including DOWNLOAD_MIRROR)

Format: https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2404-8.0.1.tgz

DOWNLOAD_IGNORE_MISSING_HEADER​

Environment VariablePackageJson
DOWNLOAD_IGNORE_MISSING_HEADERdownloadIgnoreMissingHeader

Option DOWNLOAD_IGNORE_MISSING_HEADER can be set to true to ignore missing response headers like content-length.

Default: false

PREFER_GLOBAL_PATH​

Environment VariablePackageJson
MONGOMS_PREFER_GLOBAL_PATHpreferGlobalPath

Option PREFER_GLOBAL_PATH is used to force download into ~/.cache/mongodb-binaries instead of local folder

DISABLE_POSTINSTALL​

Environment VariablePackageJson
MONGOMS_DISABLE_POSTINSTALLdisablePostinstall

Option DISABLE_POSTINSTALL is used to skip all postinstall scripts

SYSTEM_BINARY​

Environment VariablePackageJson
MONGOMS_SYSTEM_BINARYsystemBinary

Option SYSTEM_BINARY is used to set the path to an system binary already existing on the system

Format:

  • /path/to/binary/mongod (POSIX)
  • C:/path/to/binary/mongod.exe (DOS)

SYSTEM_BINARY_VERSION_CHECK​

Environment VariablePackageJson
MONGOMS_SYSTEM_BINARY_VERSION_CHECKsystemBinaryVersionCheck

Option SYSTEM_BINARY_VERSION_CHECK is used to disable the version conflict check if SYSTEM_BINARY is set and version returned from mongod_system_binary --version does not match VERSION

Default: true

MD5_CHECK​

Environment VariablePackageJson
MONGOMS_MD5_CHECKmd5Check

Option MD5_CHECK is used to enable an md5 check after download

Default: true

ARCHIVE_NAME​

Environment VariablePackageJson
MONGOMS_ARCHIVE_NAMEarchiveName

Option ARCHIVE_NAME is used to overwrite the complete archive name

Format: mongodb-linux-x86_64-ubuntu2404-8.0.1.tgz

See here for what archive names are available

This Option does not have a effect when DOWNLOAD_URL is defined.

RUNTIME_DOWNLOAD​

Environment VariablePackageJson
MONGOMS_RUNTIME_DOWNLOADruntimeDownload

Option RUNTIME_DOWNLOAD is used to disable downloading while being in something like .start

Default: true

USE_HTTP​

Environment VariablePackageJson
MONGOMS_USE_HTTPuseHttp

Option USE_HTTP is used to use http over https

Default: false

MAX_REDIRECTS​

Environment VariablePackageJson
MONGOMS_MAX_REDIRECTSmaxRedirects

Option MAX_REDIRECTS is used to set the maximal amount of redirects to follow

Default: 2

USE_ARCHIVE_NAME_FOR_BINARY_NAME​

Environment VariablePackageJson
MONGOMS_USE_ARCHIVE_NAME_FOR_BINARY_NAMEuseArchiveNameForBinaryName

Option USE_ARCHIVE_NAME_FOR_BINARY_NAME is used to use the archive name as binary

Default: false

This can resolve conflicts when resolving binary names for different systems changes between versions (like support for ubuntu 22.04 becoming available instead of using 20.04) or if the same cache is shared between different distros (like docker pass-through).

Example:

By default the binary name gets set like mongod-ARCH-CURRENT_DISTRO-VERSION (mongod-x64-ubuntu-6.0.4), but with this option it will use the downloaded archive name (without extension) like mongodb-linux-x86_64-ubuntu2004-6.0.4.

Also see ARCHIVE_NAME.

note

Keep in mind that downloaded binaries will never be automatically deleted.

MAX_RETRIES​

Environment VariablePackageJson
MONGOMS_MAX_RETRIESmaxRetries

Option MAX_RETRIES is used to set the maximum number of retry attempts for downloading binaries when a retryable error occurs.

Default: 3

Set this to control how many times the downloader will attempt to recover from transient errors (like network issues) before failing.

RESUME_DOWNLOAD​

Environment VariablePackageJson
MONGOMS_RESUME_DOWNLOADexpResumeDownload

Option RESUME_DOWNLOAD is used to enable / disable resuming a download of a binary instead of starting over on retries or interruptions.

Default: true

VALIDATE_BINARY_CHECKSUM​

Environment VariablePackageJson
MONGOMS_VALIDATE_BINARY_CHECKSUMvalidateBinaryChecksum

Option VALIDATE_BINARY_CHECKSUM is used to enable an checksum(md5) check of the already downloaded mongod binary before using it, in addition to the always-on checks for obviously truncated (too small) binaries and for a missing checksum sidecar file.

Default: false

The checksum is generated once, after a binary is extracted, and stored alongside it as <binary>.md5, in the same format md5sum --binary writes (CHECKSUM *FILENAME), so it can also be verified manually with md5sum -c <binary>.md5. Since this sidecar is only written on a successful extraction, a cached binary without one is always treated as corrupted and re-downloaded, regardless of this option (this also applies to binaries cached by a version of this package older than this check <11.3.0). Enabling this option additionally hashes the full binary on every start to catch on-disk corruption after a successful extraction (e.g. a process killed mid-write); it is off by default because of that added cost.

This option does not apply to:

  • a binary provided via SYSTEM_BINARY. System binaries are never extracted by this package, so no checksum sidecar is ever generated or checked for them.
  • the binary being validated right after extraction.

How to use them in the package.json​

To use the config options in the package.json, they need to be camelCased (and without _), and need to be in the property config.mongodbMemoryServer

Example:

{
"config": {
"mongodbMemoryServer": {
"downloadDir": "/path/to/DownloadDir"
}
}
}

By default it uses the nearest (upwards) package.json to process.cwd(). To change this:

import { findPackageJson } from "mongodb-memory-server-core/lib/util/resolveConfig";

findPackageJson('/custom/path');

// OR

process.chdir('/custom/path'); // not recommended

How to use them as Environment Variables​

For Environment Variables an config option must be prefixed with MONGOMS_

Example: MONGOMS_DOWNLOAD_DIR

For boolean Variables, the following will be interpreted as true: true 1 on yes