yargs-interactive is a JavaScript library designed to integrate interactive command-line prompts, powered by Inquirer.js, directly into yargs-based CLIs. This enables developers to create flexible command-line tools that can either parse arguments non-interactively (suitable for scripting and automation) or dynamically prompt users for missing information (for human interaction). The current stable version is 3.0.1, released in April 2022. The project's release cadence appears to be irregular, suggesting a maintenance-focused development cycle rather than active feature additions. Its key differentiation lies in its seamless blending of Yargs' robust argument parsing with Inquirer.js's user-friendly prompting, allowing the same CLI tool to serve diverse use cases, from automated CI/CD pipelines to interactive user experiences, without extensive conditional logic.
npm install yargs-interactiveVerified import paths — ran on the pinned version, not inferred.
Demonstrates the basic setup of an interactive CLI, prompting for user input if arguments are not provided via command line.
Review the `yargs` v14 migration guide and adjust CLI option definitions and usage patterns accordingly. Thorough testing is recommended.
Refer to the v2.0.0 release notes and documentation for the updated contract of the `prompt` option.
Upgrade to `yargs-interactive@^2.2.0` or `yargs-interactive@^3.0.0` immediately.
Ensure your environment uses a currently supported Node.js LTS version (e.g., Node.js 16 or newer) for security and performance.
Ensure you are using `const yargsInteractive = require("yargs-interactive");` for CommonJS environments.Verify that `yargsInteractive().interactive(options)` is called before any `argv` or `parse` methods, and that the `--interactive` flag is correctly spelled.
This library is primarily CJS. Consider sticking to CJS for your CLI entry point, or use a bundler to consume it in an ESM project.