Listr2 is a robust and highly interactive task list manager for Node.js command-line applications, designed to provide live updates and a dynamic user experience. As of version 10.2.1, it emphasizes modern JavaScript practices and is primarily used with TypeScript, shipping with comprehensive type definitions. It evolved from the original Listr package, offering a rewritten architecture for improved flexibility, extensibility, and performance, including advanced error handling, concurrent task execution, and support for multiple renderers (e.g., default, verbose, silent). Its release cadence is active, with frequent updates addressing bug fixes, dependency updates, and new features, often released in minor and patch versions. Key differentiators include its ability to manage complex multi-level tasks with live output, integration with popular prompt libraries like Inquirer.js and Enquirer through dedicated adapters, and a flexible API for customizability, making it suitable for complex CLI workflows.
npm install listr2Verified import paths — ran on the pinned version, not inferred.
Demonstrates creating a new Listr instance with main tasks and subtasks, handling context, displaying output, and managing errors with both sequential and concurrent execution.
Upgrade your Node.js environment to version 22.13.0 or newer. Consider using a Node.js version manager like `nvm` or `volta`.
Refer to the official Listr2 documentation for a comprehensive guide on the new API and migration path from `listr`.
Ensure your project is configured for ESM by setting `"type": "module"` in your `package.json` and using `import` statements. If you must use CJS, you might need to use dynamic `import()` or adjust your build pipeline.
Install the required prompt adapter, e.g., `npm install @listr2/prompt-adapter-inquirer`.
No direct action required for most users. If you had custom renderer logic tied to `colorette`, you may need to update it to use `util.styleText` or another coloring library if you desire custom styling.
Switch to ES Module import syntax: `import { Listr } from 'listr2';`. Ensure your `package.json` has `"type": "module"` if your entire project is ESM, or use a bundler if mixing CJS and ESM.Verify that you are using `import { Listr } from 'listr2';` and that your environment supports ES Modules for this package. Avoid `const Listr = require('listr2').Listr;` as it might not work reliably.Wrap your task logic in `try...catch` blocks to gracefully handle errors, or set `exitOnError: false` in the Listr options to allow other tasks to continue running even after a failure.