API Reference

listr2

Terminal task list runner that renders nested, concurrent tasks with progress, output, and error handling.

Official Documentation ↗
CompatibilityThis documentation covers version v8. Check the official docs for the latest API surface.

Installation

npmnpm install listr2
pnpmpnpm add listr2

Methods

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:

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.

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().