Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Domain
✓ import { Domain } from 'metadomain'
✗ const Domain = require('metadomain')
ESM-only; no CommonJS support.
Schema
✓ import { Schema } from 'metadomain'
✗ import Schema from 'metadomain'
Named export, not default.
Field
✓ import { Field } from 'metadomain'
✗ const { Field } = require('metadomain')
ESM-only.
Demonstrates creating a domain, defining a schema with fields, and creating an entity instance.
import { Domain, Schema, Field } from 'metadomain';
const schema = new Schema('example', {
fields: [
new Field('id').integer().primary(),
new Field('name').string(100).required(),
new Field('email').string().email(),
],
});
const domain = new Domain();
domain.entity('User', schema);
const user = domain.create('User', { name: 'John', email: 'john@example.com' });
console.log(user.toObject());
Debug
Known issues
breakingMetadomain v2.0.0-alpha.x is not backward compatible with v1.x; schema definition API has changed.fixRefer to migration guide; use new Field and Schema constructors.
affects: >=2.0.0-alpha.0 <2.0.0
breakingRemoved support for Node.js versions below 18 in v2.0.0-alpha.fixUpgrade Node.js to version 18, 20, 21, or 22.
affects: >=2.0.0-alpha.0
deprecatedThe `Domain` constructor with string arguments for types is deprecated; use object configuration.fixPass configuration object: new Domain({ types: ... }). affects: >=1.0.0 <2.0.0
gotchaFields must be added to a Schema using an array in the constructor; mutations after creation are not reflected.fixDefine all fields in the schema constructor.
affects: >=1.0.0
gotchaThe library is ESM-only; using require() will throw an error.fixUse ES module imports or dynamic import().
affects: >=2.0.0-alpha.0
Errors
Common errors & fixes
Cannot find module 'metadomain'
Package not installed or wrong import path in CJS project.
fixInstall: npm install metadomain. If using CJS, use dynamic import: import('metadomain'). TypeError: Domain is not a constructor
Using require() on an ESM-only package.
fixSwitch to ES module syntax: import { Domain } from 'metadomain'. Error: Unknown field type 'custom'
Trying to use an unsupported field type.
fixUse built-in types: integer, string, boolean, etc. Or define custom type via schema options.
Schema validation error: Field 'email' must be a valid email
Email validation fails on entity creation.
fixEnsure field value passes built-in email validation; or remove .email() constraint.
Upgrade
Version history
2.0.0-alpha.2latest on npm
Audit
Dependencies
@metarhia/commonrequiredProvides common utilities used by Metadomain.
metatypesrequiredProvides type checking and validation utilities.