Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save ben-vargas/9c977f6c32318727d8aef3211ed99d96 to your computer and use it in GitHub Desktop.

Select an option

Save ben-vargas/9c977f6c32318727d8aef3211ed99d96 to your computer and use it in GitHub Desktop.

🧠 Issue Summary

The complexity-report command fails with a require is not defined error when prompting the user to generate a new report. This occurs if the report file is missing at:

.taskmaster/reports/task-complexity-report.json

πŸ” Root Cause

In scripts/modules/ui.js at line 1685, the displayComplexityReport function uses a CommonJS require('readline') statement inside an ES module. This leads to a runtime error since ES modules do not support require().


πŸ”§ Fix Plan

  1. Update the readline import to use dynamic import() syntax:

    • Replace:

      const readline = require('readline').createInterface({
        input: process.stdin,
        output: process.stdout
      });
    • With:

      const readline = await import('readline');
      const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
      });
  2. Update references accordingly:

    • Change readline.question() β†’ rl.question()
    • Change readline.close() β†’ rl.close()
  3. Note:

    • This aligns with the dynamic import pattern already used elsewhere in the same file (e.g., lines 1977–1979).
    • It ensures consistency with ES module syntax across the project and resolves the runtime error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment