{"id":18694,"library":"pug-cli","title":"Pug CLI","description":"Command-line interface for Pug (formerly Jade) template engine, version 1.0.0-alpha6. Allows compiling .pug files to HTML or client-side JavaScript. Supports watching, pretty-printing, custom output directories, and options via JSON/JS files. Primarily used for build tooling and static site generation. Maintained as part of the Pug project, though the CLI is in alpha with infrequent releases. Alternatives include gulp-pug or webpack loaders for integrated workflows.","status":"active","version":"1.0.0-alpha6","language":"javascript","source_language":"en","source_url":"https://github.com/pugjs/pug-cli","tags":["javascript"],"install":[{"cmd":"npm install pug-cli","lang":"bash","label":"npm"},{"cmd":"yarn add pug-cli","lang":"bash","label":"yarn"},{"cmd":"pnpm add pug-cli","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core template engine required for compilation","package":"pug","optional":false},{"reason":"Command-line argument parsing","package":"commander","optional":false},{"reason":"Directory creation for output","package":"mkdirp","optional":false}],"imports":[{"note":"CLI tool, not a module. Use npx pug or install globally.","wrong":"pug -c file.pug (without --client, outputs HTML)","symbol":"pug command","correct":"pug file.pug"},{"note":"pug-cli is a CLI, not a module. Use require('pug') for API.","wrong":"require('pug-cli')","symbol":"require('pug')","correct":"require('pug')"},{"note":"Import pug module, not pug-cli.","wrong":"pug.compile() directly (missing require)","symbol":"pug.compile()","correct":"const pug = require('pug'); pug.compile('...')"}],"quickstart":{"code":"npm install -g pug-cli\n# Create a Pug template\necho 'h1 Hello #{name}' > template.pug\n# Compile with variable\necho '{\"name\": \"World\"}' | pug -O /dev/stdin template.pug\ncat template.html","lang":"javascript","description":"Install pug-cli globally, create a .pug file, compile with JSON options from stdin, output HTML."},"warnings":[{"fix":"Use --client only for client-side compilation, and include pug-runtime in your project.","message":"When using --client, the output is a JavaScript function, not HTML. You need to include the Pug runtime.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use --name explicitly instead.","message":"The --name-after-file option may be removed in future versions.","severity":"deprecated","affected_versions":">=1.0.0-alpha6"},{"fix":"Ensure output directory exists before running, or use mkdirp.","message":"Output directory is not created automatically if it doesn't exist; pug-cli will error.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use double quotes for JSON: pug -O '{\"key\": \"value\"}' file.pug","message":"The -O option with JSON string must be a valid JSON object, not a JavaScript object literal with single quotes.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure all template files have .pug extension.","message":"When using watch mode, only changes to files with .pug extension trigger re-render. Other file changes are ignored.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install -g pug-cli","cause":"pug-cli is not installed globally","error":"pug: command not found"},{"fix":"npm install pug","cause":"pug package is not installed locally or globally","error":"Cannot find module 'pug'"},{"fix":"Create output directory: mkdir -p <outdir>","cause":"Output directory does not exist","error":"ENOENT: no such file or directory"},{"fix":"Use valid JSON with double quotes: pug -O '{\"key\": \"value\"}' file.pug","cause":"Invalid JSON string passed to -O","error":"SyntaxError: Unexpected token } in JSON"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}