listr2
Terminal task list runner that renders nested, concurrent tasks with progress, output, and error handling.
Official Documentation ↗v8. Check the official docs for the latest API surface.Installation
npm install listr2pnpm add listr2Methods
No methods match this filter.
Overview
listr2 is a terminal task list runner that renders nested, concurrent tasks with progress, live output, and structured error handling. This reference lists the most frequently used APIs with accurate signatures and runnable snippets.
Core APIs
new Listr— Creates a task list from task definitions with optional renderer and concurrency options.listr.run— Executes the tasks in order and resolves with the shared context object.Task— Task definition with a title, runnable body, and optional enablement predicate.
Example
const { Listr } = require('listr2');
const listr = new Listr([
{ title: 'Build', task: async () => { await build(); } },
{ title: 'Test', task: async () => { await test(); } },
]);
Notes
Tasks share a context object for passing data. Concurrency should be enabled only for tasks that do not depend on each other.
Verification
Run a two-task list with concurrency off and confirm the second task title only activates after the first completes.
Errors
The official API reference declares the following error types:
ListrError(错误类(Listr.errors 数组的元素类型)) — official text: “errors :ListrError<Ctx>[]” (source: https://listr2.kilic.dev/api/listr2/classes/Listr.html, fetched 2026-11-08T20:09:00+08:00)
API reference evidence
Fetched from official sources on 2026-11-08T20:09:00+08:00 via WebFetch https://listr2.kilic.dev/;WebFetch https://listr2.kilic.dev/listr/listr.html;WebFetch https://listr2.kilic.dev/api/listr2/classes/Listr.html.
new Listr→ signature from https://listr2.kilic.dev/api/listr2/classes/Listr.html; official text: “new Listr <Ctx,Renderer,FallbackRenderer>(task,options?,parentTask?):Listr<Ctx,Renderer,FallbackRenderer>”listr.run→ signature from https://listr2.kilic.dev/api/listr2/classes/Listr.html; official text: “run (context?):Promise<Ctx>”
FAQ
- How do I run tasks concurrently?
- Set concurrent: true in the Listr options, which runs independent tasks in parallel while keeping nested ones ordered.
- How do I pass data between tasks?
- Use the shared context object passed to run; each task receives and can mutate it.
- Can a task be skipped conditionally?
- Provide an enabled predicate returning false to skip a task, or skip a task at runtime with task.skip().
Report a problem with this API docOpens a pre-filled issue on GitHub.