affaan-m/ECC · error · Error

ENOENT

ENOENT

Error message

pandoc did not produce a DOCX artifact

What it means

This error is thrown by build-agreement.js after it invokes pandoc to generate a DOCX file. The script lstat's the expected output path inside a try block; if pandoc never created the file, lstatSync fails with ENOENT and the catch block replaces it with this clearer message. It signals the external pandoc tool failed or was never invoked successfully.

Solutions

  1. Install pandoc (e.g. `brew install pandoc`, `apt install pandoc`, or `choco install pandoc`) and verify with `pandoc --version`.
  2. Run the script again and check stderr for the underlying pandoc error (e.g. unrecognized format or read failure).
  3. Confirm the output directory in the script's configuration exists and is writable so pandoc can create docxPath.
  4. Pin a recent pandoc version in CI to avoid flag/format incompatibilities.

Example fix

# before
$ node build-agreement.js  # Error: pandoc did not produce a DOCX artifact
# after
$ pandoc --version         # ensure installed and on PATH
$ node build-agreement.js  # docx generated
Defensive patterns

Strategy: validation

Validate before calling

const { execSync } = require('child_process');
try { execSync('pandoc --version', { stdio: 'ignore' }); } catch { throw new Error('pandoc is required but not installed/on PATH'); }

Type guard

null

Try / catch

try {
  await buildAgreement(opts);
} catch (e) {
  if (/pandoc did not produce/.test(e.message)) {
    console.error('pandoc missing or failed; install pandoc and retry:', e.message);
  } else throw e;
}

Prevention

When it happens

Trigger: Running the build-agreement script when pandoc is not installed, not on PATH, exits nonzero, or writes its output to a different path than docxPath (e.g. wrong --output directory or working directory).

Common situations: Fresh machines without pandoc installed; CI images missing the pandoc dependency; a pandoc version that rejects the input format; running from a directory where the relative docxPath does not resolve; pandoc failing on malformed Markdown front matter.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/7c3a9c7e521246c6. Report an issue: GitHub.

Appendix: source

Thrown at skills/master-agreement-generator/scripts/build-agreement.js:192

    result.docxSkipped = true;
    return result;
  }
  const canConvert = options.pandoc === undefined ? pandocAvailable() : options.pandoc;
  if (!canConvert) {
    throw new Error('DOCX required: pandoc unavailable; use --markdown-only for an explicit Markdown-only draft');
  }
  try {
    const converted = spawnSync('pandoc', [mdPath, '-o', docxPath], CONVERTER_OPTIONS);
    if (converted.error || converted.status !== 0) {
      throw new Error('pandoc conversion failed; DOCX unavailable');
    }
    const artifact = fs.lstatSync(docxPath);
    if (!artifact.isFile() || artifact.size === 0) {
      throw new Error('pandoc did not produce a nonempty regular DOCX artifact');
    }
  } catch (error) {
    fs.rmSync(docxPath, { force: true });
    if (error.code === 'ENOENT') throw new Error('pandoc did not produce a DOCX artifact');
    throw error;
  }
  result.docx = docxPath;
  return result;
}

function main(argv) {
  const [templatePath, specPath, outDir, ...flags] = argv;
  if (!templatePath || !specPath || !outDir ||
      flags.some(flag => !['--require-docx', '--markdown-only'].includes(flag)) ||
      flags.length > 1) {
    console.error('usage: build-agreement.js <template.md> <spec.json> <out_dir> [--require-docx | --markdown-only]');
    return 2;
  }
  try {
    const result = build(templatePath, specPath, outDir, { markdownOnly: flags.includes('--markdown-only') });
    console.log(`wrote ${result.documentStatus} ${result.markdown}`);
    if (result.docxSkipped) {

View on GitHub (pinned to 8321021c54)