nunjucks-cli

raw JSON →
1.0.0 verified Sat Apr 25 auth: no javascript

A CLI wrapper and file watcher for Nunjucks templates, enabling compilation of Nunjucks files to static HTML. Version 1.0.0, released as an initial stable version, works as a command-line tool for rendering templates with JSON data and watching for changes. Key differentiators: built-in watcher for automatic re-rendering, support for glob patterns, process.env injection as context, and sensible defaults like ignoring partials starting with underscore.

error nunjucks: command not found
cause Installed locally without global link or npx
fix
Use npx nunjucks or install globally with npm i -g nunjucks-cli then run nunjucks.
gotcha Template files starting with underscore (_) are ignored by default
fix Rename files without underscore or use a different tool if you need to compile underscore-prefixed templates.
npm install nunjucks-cli
yarn add nunjucks-cli
pnpm add nunjucks-cli

Shows basic rendering with a template and JSON data, then watching all templates for changes.

# Create a sample template
echo 'Hello {{ name }}!' > hello.tpl
# Create a sample data file
echo '{"name": "World"}' > data.json
# Render the template to HTML
npx nunjucks hello.tpl data.json
# Output: hello.html with content 'Hello World!'
# Watch mode for auto-recompilation
npx nunjucks **/*.tpl --watch