CLI and API to retrieve the MongoDB version from a local mongod binary path, a running MongoDB URI, or a Db instance. v2.0.1 is stable but low activity; maintained as part of MongoDB-js ecosystem. Differentiates from manual parsing by abstracting `--version` execution and server connection/serverInfo queries into a single function call.
npm install get-mongodb-versionNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates retrieving MongoDB version from a binary path and from a URI using the library.
Update to Node >=10 and use import/ESM syntax.
Call getMongodbVersion(db, callback) instead of getMongodbVersion({ db: db }, callback).Run npm install mongodb in your project.
Ensure the package is installed globally or use npx.
npm install get-mongodb-version
Use import getMongodbVersion from 'get-mongodb-version' or const getMongodbVersion = require('get-mongodb-version')Start mongod or check the URI.
Pass the Db instance directly: getMongodbVersion(db, callback)