Installation
The packages are ES modules only, with no CommonJS build. They need a runtime with ES2023: Node.js 22.12 or later, a current Bun or Deno, or a browser through a bundler.
Install
sh
pnpm add einvoice-tssh
npm install einvoice-tssh
yarn add einvoice-tssh
bun add einvoice-tssh
deno add npm:einvoice-tsThe packages bring their own type declarations. TypeScript resolves them with moduleResolution set to bundler, node16 or nodenext.
Import
Everything is a named export of the umbrella package:
ts
import { createInvoice, parse, serialize, validate, validateXml } from 'einvoice-ts';The single packages export the same names:
ts
import { createInvoice, Decimal } from '@einvoice-ts/core';
import { parseInvoice } from '@einvoice-ts/parser';
import { serialize } from '@einvoice-ts/serializer';
import { en16931Ruleset, peppolRuleset, validate } from '@einvoice-ts/validator';The code lists and the runtime schema are subpath exports. Each code list is its own module, so importing the tax categories does not pull the 2162 unit codes into your bundle:
ts
import { isTaxCategoryCode, TAX_CATEGORY_CODES } from '@einvoice-ts/core/codelists/tax-category';
import { toXPath } from 'einvoice-ts/schema';
isTaxCategoryCode('S'); // true, and narrows the string to TaxCategoryCode
const codes = TAX_CATEGORY_CODES.length; // 10
const xpath = toXPath(['invoiceLine', 0, 'price', 'priceAmount'], 'Invoice');
// '/ubl:Invoice/cac:InvoiceLine[1]/cac:Price/cbc:PriceAmount'Runtimes
| Runtime | Support |
|---|---|
| Node.js ≥ 22.12 | Supported. CI runs the tests and a smoke test of the packed packages on Node 24. |
| Bun, Deno | Supported by design (no Node.js APIs in the packages); not tested in CI. |
| Browsers | Supported by design through a bundler; not tested in CI. |
The libraries never touch process, Buffer, the file system or the DOM, and CI builds them for a neutral platform, so any node: import fails the build.