m.js: GT.M binding for Node.js
raw JSON → 0.1.0-56-g1b5486c verified Sat Apr 25 auth: no javascript
Node.js binding to the GT.M hierarchical (MUMPS) database. The current version is 0.1.0-56-g1b5486c (pre-release from git). The package wraps the GT.M C API to allow Node.js to read and write to GT.M global nodes. It uses GNP (GT.M Network Protocol) or direct call-in. Key differentiator: it is the only Node.js binding for GT.M with native bindings, but it is experimental and uses a pre-1.0 version. It requires GT.M to be installed and configured.
Common errors
error Error: Module did not self-register. ↓
cause The compiled native addon is not compatible with the current Node.js version.
fix
Recompile the addon: npm rebuild gtm or use node-gyp rebuild.
error Error: Could not locate the bindings file. ↓
cause Missing or incorrectly built native module; package installation did not compile.
fix
Install node-gyp and required build tools, then run: node-gyp configure build within the module directory.
error ReferenceError: gtm is not defined ↓
cause Using require incorrectly or package not installed.
fix
Install the package: npm install gtm and use const gtm = require('gtm');
error Error: connect ECONNREFUSED 127.0.0.1:1234 ↓
cause GT.M listener not running or wrong host/port.
fix
Start GT.M with GNP listener: gtm_gnp_server -PORT=1234 -SERVICE=^DEFAULT
Warnings
breaking Native addon requires GT.M development headers and Node.js build tools; fails to install or load without them. ↓
fix Install GT.M (e.g., gtm, gt.m-devel) and node-gyp. Ensure GTM_DIST environment variable is set.
gotcha Package version uses git describe format (0.1.0-56-g1b5486c); npm registry may have different versioning. ↓
fix Use exact version from git tag or local copy if registry version is outdated.
gotcha open() requires a fully configured GT.M listener; no default parameters work out of the box. ↓
fix Make sure GT.M is running with proper GNP configuration (port, namespace).
breaking Incompatible with Node.js versions beyond 0.12 due to deprecated V8 API usage. ↓
fix Use Node.js <=0.12; or fork and update nan/binding to modern N-API.
gotcha set() and get() use global reference syntax; not following GT.M syntax causes runtime errors. ↓
fix Ensure global names start with ^ and subscripts are comma-separated in the string.
Install
npm install gtm yarn add gtm pnpm add gtm Imports
- gnp wrong
import gnp from 'gtm';correctconst gnp = require('gtm'); - close wrong
const { close } = require('gtm').close;correctconst { close } = require('gtm'); - open wrong
const gtm = require('gtm'); gtm.open();correctconst { open } = require('gtm'); - set wrong
const { set } = require('gtm/set');correctconst { set } = require('gtm'); - get wrong
const get = require('gtm').get;correctconst { get } = require('gtm');
Quickstart
const gtm = require('gtm');
const conn = gtm.open({host: process.env.GTM_HOST ?? '127.0.0.1', port: process.env.GTM_PORT ?? 1234, namespace: process.env.GTM_NAMESPACE ?? 'DEFAULT'});
gtm.set(conn, '^MyGlobal("key1")', 'value1');
const val = gtm.get(conn, '^MyGlobal("key1")');
console.log(val);
gtm.close(conn);
conn.close();