For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /installation.md.

Installation

Requirements

  • Massaman is ESM-only. Your runtime or bundler must support ES modules.
  • Node.js 26 or newer is required when running Massaman in Node.js.

Install

pnpm
npm
yarn
bun
pnpm add massaman

There are no peer dependencies. es-toolkit and ts-pattern are installed automatically.

Try it

import { attempt, match, P } from 'massaman'

const config = attempt<{ ready: boolean }>(() => JSON.parse('{"ready":true}'))

const message = match(config)
  .with(P.ok({ ready: true }), () => 'Massaman is ready')
  .with(P.ok(), () => 'Massaman is not ready')
  .with(P.err(), ({ error }) => `Invalid config: ${error.message}`)
  .exhaustive()

console.log(message)

Troubleshooting

TypeScript cannot resolve massaman

Use a modern module resolver in tsconfig.json:

{
  "compilerOptions": {
    "moduleResolution": "bundler",
  },
}

Use "nodenext" instead when TypeScript should follow Node.js module resolution.

CommonJS cannot load massaman

Massaman does not ship a CommonJS build. Migrate the project to ESM or load Massaman with a dynamic import:

async function main() {
  const { attempt } = await import('massaman')
  return attempt(() => JSON.parse('{"ready":true}'))
}

main()
Node.js reports an unsupported engine

Upgrade to Node.js 26 or newer. That is the minimum version declared by the package.