Registry / database / mongodb-dbpath

mongodb-dbpath

JSON →
library0.0.1jsnpmunverified

A utility to obtain a writeable filesystem path suitable for MongoDB's --dbpath option, creating the directory if it doesn't exist. Version 0.0.1 is the only release; no maintenance or release cadence indicated. It differentiates by platform: on Travis CI uses process.cwd(), on AppVeyor uses LOCALAPPDATA, and on local laptops defaults to ~/.mongodb/data/<name>. Useful for scripts that need a predictable MongoDB data directory across environments.

npm install mongodb-dbpath
INSTALL
IMPORT
SIG · MONGODB-DBPATH
M
mongodb-dbpath
databasejavascriptv0.0.1
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.

default
var dbpath = require('mongodb-dbpath');
import dbpath from 'mongodb-dbpath';
This package is CJS-only; ESM import will not work.

Shows how to use dbpath function to get a writable MongoDB data directory path.

var dbpath = require('mongodb-dbpath'); dbpath({ name: 'my-db' }, function(err, res) { if (err) { console.error(err); return; } console.log('Using dbpath:', res); // output: ~/.mongodb/data/my-db (on laptop) });
Debug
Known issues
gotchaThe package only accepts an opts object with a 'name' property; passing string directly will fail.
fix
Always pass an object { name: 'your-dir' }.
affects: >=0.0.0
gotchaOn Travis CI, the path uses process.cwd() which may not be writable if not configured correctly.
fix
Ensure process.cwd() is writable or set HOME environment variable.
affects: >=0.0.0
gotchaOn Windows (AppVeyor), the path uses LOCALAPPDATA environment variable; if not set, it may fall back incorrectly.
fix
Ensure LOCALAPPDATA is set or use a different method.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: Cannot read property 'name' of undefined
Calling dbpath() without an opts object or with undefined/null.
fix
Pass an opts object: dbpath({ name: 'my-db' }, callback);
Error: EACCES: permission denied, mkdir '/.mongodb'
The determined path (e.g., on Travis) may not be writable.
fix
Set HOME environment variable to a writable directory or adjust permissions.
Upgrade
Version history
0.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Resources
mongodb-dbpath — npm install mongodb-dbpath · libregistry