Prerequisites
Before installing UBL Builder, ensure you have:Package Installation
Install UBL Builder using your preferred package manager:Package Details
Once installed, you’ll have access to:- Main Export:
Invoiceclass for building UBL 2.1 invoices - Type Definitions: Full TypeScript types for all components
- Aggregate Components: Pre-built UBL components for parties, addresses, taxes, etc.
- Data Types: UBL Unqualified Data Types (UDT)
The package is distributed as compiled JavaScript with TypeScript declaration files, so it works in both TypeScript and JavaScript projects.
Importing the Library
TypeScript / ES Modules
CommonJS / Node.js
Available Exports
The main entry point exports:Most aggregate components are accessed through the
Invoice class methods rather than direct imports.TypeScript Configuration
For optimal TypeScript support, ensure yourtsconfig.json includes:
tsconfig.json
Dependencies
UBL Builder includes the following dependencies (automatically installed):| Package | Version | Purpose |
|---|---|---|
@xmldom/xmldom | ^0.8.10 | XML DOM implementation |
xmlbuilder | ^15.1.1 | XML document construction |
xpath | 0.0.29 | XPath query support |
weeknumber | ^1.1.2 | Date utilities |
Verification
Verify your installation by running a simple test:test.ts
UBL Builder installed successfully!
Development Setup
If you’re contributing to UBL Builder or want to build from source:Development Scripts
package.json
Troubleshooting
Module not found error
Module not found error
Ensure you’ve installed the package correctly:Check that
node_modules contains the ubl-builder directory.TypeScript type errors
TypeScript type errors
Make sure your TypeScript version is 4.0 or higher:Enable
esModuleInterop in your tsconfig.json.Runtime errors with XML generation
Runtime errors with XML generation
The XML dependencies should be installed automatically. If you encounter issues:
Next Steps
Quickstart Guide
Build your first UBL invoice
API Reference
Explore all available methods and types