Registry / devops / mongodb-realm-cli

mongodb-realm-cli

JSON →
library2.6.2jsnpmunverified

The MongoDB Realm CLI (v2.6.2) is a command-line tool for managing MongoDB Realm applications (now called Atlas App Services). It allows developers to create, deploy, import/export, and configure Realm apps from the terminal. The CLI interacts with the Realm and Atlas APIs, supporting CI/CD workflows. The project is written in Go but distributed via npm as a Node.js wrapper. Releases are irregular; the latest version is from October 2023. Key differentiators: it is the official tool from MongoDB for App Services, enabling local development, app templating, and automation. Note that Realm is rebranded to Atlas App Services, but the CLI retains the 'realm' naming.

npm install mongodb-realm-cli
INSTALL
IMPORT
SIG · MONGODB-REALM-CLI
M
mongodb-realm-cli
devopsjavascriptv2.6.2
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.

MongoDB Realm CLI command
npx mongodb-realm-cli login
npm install -g mongodb-realm-cli && realm-cli login
Prefer npx to avoid global install; the executable is named 'realm-cli' after npm install
Default export from npm package
const { execSync } = require('child_process'); execSync('npx mongodb-realm-cli --version');
const realm = require('mongodb-realm-cli'); realm.login();
This package is a CLI tool, not a library; import it as a command, not a module
Node.js require for programmatic use
import { exec } from 'child_process'; const result = await exec('npx mongodb-realm-cli push --local');
import realm from 'mongodb-realm-cli';
The package exposes no JavaScript API; it must be invoked as a child process

Demonstrates global install, authentication, app creation from template, deployment, and export using the CLI.

npm install -g mongodb-realm-cli # Login with Atlas API key realm-cli login --api-key="$(process.env.ATLAS_API_KEY ?? '')" --private-api-key="$(process.env.ATLAS_PRIVATE_API_KEY ?? '')" # Create a new app from a template realm-cli apps create --name MyApp --template graphql # Deploy local changes realm-cli push --local --remote=MyApp # Export an existing app realm-cli pull --remote=MyApp --local=./my-app
Debug
Known issues
gotchaThe npm package is a thin wrapper around a Go binary; it does not provide a JavaScript API for programmatic use.
fix
Use child_process.exec or spawn to invoke 'mongodb-realm-cli' as a command.
affects: >=1.0.0
gotchaThe package name is 'mongodb-realm-cli' but the executable installed is 'realm-cli'.
fix
After npm install -g, use 'realm-cli' command, not 'mongodb-realm-cli'.
affects: >=1.0.0
deprecatedMongoDB Realm is now called Atlas App Services. The CLI has not been renamed; 'realm' naming is legacy but still supported.
fix
Use the CLI as-is; Atlas App Services endpoints remain compatible.
affects: >=2.0.0
breakingThe minimum Node.js engine is 4.0.0, but Node 4 is end-of-life and many modern features may not work. The Go binary may not function correctly on very old Node versions.
fix
Use Node.js >=12 (preferably LTS) to run the CLI.
affects: >=1.0.0
gotchaAuthentication requires Atlas API keys with appropriate permissions; the 'login' command stores credentials in a profile file (~/.mongodb/).
fix
Ensure API key has 'Project Owner' role and that the profile is correctly set.
affects: >=1.0.0
Errors
Common errors & fixes
Error: EACCES: permission denied, unlink '/usr/local/lib/node_modules/.cache/...'
Installing the CLI globally without sudo leads to permission issues with the npm cache.
fix
Use npx instead of global install, or install with 'sudo npm install -g mongodb-realm-cli'.
realm-cli: command not found
The global npm bin directory is not in your PATH after installation.
fix
Add '/usr/local/bin' to PATH, or use 'npx mongodb-realm-cli' instead.
Error: Could not authenticate: Invalid API Key
The API key or private key is incorrect or does not have the right permissions.
fix
Verify key at Atlas UI, ensure it's active, and has at least Project Read/Write role.
Error: request failed with status code 401
Session token expired or invalid credentials in the profile.
fix
Run 'realm-cli logout' then 'realm-cli login --api-key=... --private-api-key=...' again.
Upgrade
Version history
2.6.2latest on npm
Audit
Dependencies
noderequiredruntime engine required (>=4.0.0, but modern usage requires >=12)
Agent activity
7 hits · last 30 days
node
6
Resources
mongodb-realm-cli — npm install mongodb-realm-cli · libregistry