{"id":14388,"library":"yargs-interactive","title":"Interactive Prompting for Yargs CLIs","description":"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.","status":"maintenance","version":"3.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/nanovazquez/yargs-interactive","tags":["javascript","yargs","interactive","cli","arguments","args","prompt","inquirer"],"install":[{"cmd":"npm install yargs-interactive","lang":"bash","label":"npm"},{"cmd":"yarn add yargs-interactive","lang":"bash","label":"yarn"},{"cmd":"pnpm add yargs-interactive","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core dependency for parsing command-line arguments and defining CLI structure.","package":"yargs"},{"reason":"Core dependency for handling interactive prompts and user input.","package":"inquirer"}],"imports":[{"note":"This library is primarily CommonJS. While Node.js can sometimes interop, direct ESM 'import' might not work as expected without a bundler or specific configuration, leading to `TypeError: yargsInteractive is not a function` or `ReferenceError: require is not defined` if used in an ESM file.","wrong":"import yargsInteractive from 'yargs-interactive';","symbol":"yargsInteractive","correct":"const yargsInteractive = require(\"yargs-interactive\");"},{"note":"The `interactive` method is called on the builder returned by `yargsInteractive()`, not directly on the imported module object.","wrong":"yargsInteractive.interactive(options)","symbol":".interactive(options)","correct":"yargsInteractive().interactive(options)"}],"quickstart":{"code":"#!/usr/bin/env node\n\nconst yargsInteractive = require(\"yargs-interactive\");\n\nconst options = {\n  name: { type: \"input\", default: \"A robot\", describe: \"Enter your name\" },\n  likesPizza: { type: \"confirm\", default: false, describe: \"Do you like pizza?\" }\n};\n\nyargsInteractive()\n  .usage(\"$0 <command> [args]\")\n  .interactive(options)\n  .then(result => {\n    // Your business logic goes here.\n    // Get the arguments from the result\n    console.log(`\\nResult is:\\n` + `- Name: ${result.name}\\n` + `- Likes pizza: ${result.likesPizza}\\n`);\n  });","lang":"javascript","description":"Demonstrates the basic setup of an interactive CLI, prompting for user input if arguments are not provided via command line."},"warnings":[{"fix":"Review the `yargs` v14 migration guide and adjust CLI option definitions and usage patterns accordingly. Thorough testing is recommended.","message":"Version 3.0.0 introduced breaking changes by updating its underlying `yargs` dependency to v14. Users upgrading from v2.x should consult the `yargs` v14 release notes for potential incompatibilities.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Refer to the v2.0.0 release notes and documentation for the updated contract of the `prompt` option.","message":"Version 2.0.0 introduced breaking changes to the `prompt` option's contract. Implementations using custom `prompt` behavior will need to be updated.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Upgrade to `yargs-interactive@^2.2.0` or `yargs-interactive@^3.0.0` immediately.","message":"Versions prior to 2.2.0 contained security vulnerabilities. It is crucial to upgrade to v2.2.0 or newer to ensure your CLI is protected against known issues.","severity":"gotcha","affected_versions":"<2.2.0"},{"fix":"Ensure your environment uses a currently supported Node.js LTS version (e.g., Node.js 16 or newer) for security and performance.","message":"The minimum Node.js version required is 8. While it may still function on Node.js 8, this version is long End-of-Life and lacks critical security updates and modern JavaScript features. It's recommended to run on a supported Node.js version.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'2022':72 '3.0.1':68 'activ':91 'addit':93 'allow':114 'appear':78 'april':71 'arg':141 'argument':44,105,140 'autom':52,125 'base':28 'blend':101 'cadenc':77 'case':123 'ci/cd':126 'cli':117,139 'clis':5,29 'command':18,37 'command-lin':17,36 'condit':134 'creat':34 'current':64 'cycl':88 'design':13 'develop':32,87 'differenti':96 'direct':24 'divers':121 'dynam':54 'either':42 'enabl':31 'experi':131 'extens':133 'featur':92 'flexibl':35 'focus':86 'friend':112 'human':61 'inform':59 'inquir':143 'inquirer.js':23,108 'integr':15 'interact':1,8,16,47,62,129,138 'irregular':81 'javascript':11,136 'key':95 'librari':12 'lie':97 'line':19,38 'logic':135 'mainten':85 'maintenance-focus':84 'miss':58 'non':46 'non-interact':45 'pars':43,106 'pipelin':127 'power':21 'project':74 'prompt':2,20,55,113,142 'rather':89 'releas':69,76 'robust':104 'script':50 'seamless':100 'serv':120 'stabl':65 'suggest':82 'suitabl':48 'tool':39,118 'use':122 'user':56,111,130 'user-friend':110 'version':66 'without':132 'yarg':4,7,27,103,137 'yargs-bas':26 'yargs-interact':6","created_at":"2026-04-20T01:59:26.703643+00:00","updated_at":"2026-04-20T01:59:26.703643+00:00","problems":[{"fix":"Ensure you are using `const yargsInteractive = require(\"yargs-interactive\");` for CommonJS environments.","cause":"Attempting to call `yargsInteractive()` when it's not correctly imported/required, often due to ESM `import` in a CJS context or destructuring.","error":"TypeError: yargsInteractive is not a function"},{"fix":"Verify that `yargsInteractive().interactive(options)` is called before any `argv` or `parse` methods, and that the `--interactive` flag is correctly spelled.","cause":"The `--interactive` flag is not being properly recognized by the `yargs` instance because `.interactive(options)` has not been called on the builder before parsing arguments, or the flag itself is misspelled.","error":"Error: Unknown option: --interactive"},{"fix":"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.","cause":"Using `require()` in a JavaScript file that is treated as an ES module (e.g., `.mjs` file or `\"type\": \"module\"` in `package.json`).","error":"ReferenceError: require is not defined in ES module scope"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/nanovazquez/yargs-interactive","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/yargs-interactive","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","web-framework","http-networking"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}