Installation¶
Complete guide to installing and verifying miki-template in different environments.
Requirements¶
-
Node.js 18.x or 20.x (Node 18+ required for
URL,fetch, and other Web API globals used by the engine) -
npm 9+, pnpm, or yarn
-
Bun (optional) — miki-template is fully compatible with Bun
Install via npm¶
Install via pnpm¶
Install via yarn¶
Install via Bun¶
Package.json "type" Considerations¶
miki-template ships a dual CommonJS/ESM package:
-
CommonJS entry:
src/index.js— importable viarequire('miki-template')orimport(Node auto-detects theimportcondition). -
ESM entry:
src/esm.mjs— importable viaimport ... from 'miki-template'.
| Your project uses | How to import |
|---|---|
| CommonJS ("type": "commonjs" or no type field) | const miki = require('miki-template') |
| ES Modules ("type": "module") | import miki from 'miki-template' or import { render } from 'miki-template' |
| TypeScript /Bun | Same as ESM — import syntax works directly |
Tip: If your project is ESM-only (no
"type"field but using.mjsfiles), use named imports:import { render, compile } from 'miki-template'.
Verifying the Installation¶
Troubleshooting¶
"Cannot find module 'miki-template'"¶
Ensure the package is installed in the correct node_modules directory. If you're working in a monorepo, run npm install from the package root.
Auto-escaping produces & where you expect &¶
This is by design — miki-template escapes all variables by default to prevent XSS. Use |safe or markSafe() for trusted HTML:
See Security for details.