{"id":16964,"library":"cli-prompt","title":"cli-prompt: Tiny CLI Prompter","description":"cli-prompt is a lightweight utility designed for creating interactive command-line prompts in Node.js applications. It provides a simple, callback-based API for collecting user input, including basic text prompts, hidden password input, and multi-question sequences. Despite its functionality, the package is considered abandoned, with its last known publication being `0.6.0` over 10 years ago and no significant updates or active maintenance since 2013. This project distinguishes itself through its minimal footprint and straightforward API, contrasting with more modern, promise-based or feature-rich prompt libraries that offer advanced validation, styling, and asynchronous patterns. Due to its abandonment, developers should consider its lack of ongoing support and potential compatibility or security issues.","status":"abandoned","version":"0.6.0","language":"javascript","source_language":"en","source_url":"git://github.com/carlos8f/node-cli-prompt","tags":["javascript","prompt","cli","readline","input","terminal","console","wizard"],"install":[{"cmd":"npm install cli-prompt","lang":"bash","label":"npm"},{"cmd":"yarn add cli-prompt","lang":"bash","label":"yarn"},{"cmd":"pnpm add cli-prompt","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package uses CommonJS 'require' syntax. It is not compatible with ES Modules directly without a CommonJS wrapper or bundler.","symbol":"prompt","correct":"const prompt = require('cli-prompt');"},{"note":"Accesses the password input function directly as a property of the main 'prompt' export.","symbol":"prompt.password","correct":"const prompt = require('cli-prompt');\nprompt.password('...', cb);"},{"note":"Used for collecting multiple inputs or questions in sequence, accessed as a property of the main 'prompt' export.","symbol":"prompt.multi","correct":"const prompt = require('cli-prompt');\nprompt.multi([...], cb);"}],"quickstart":{"code":"const prompt = require('cli-prompt');\n\nconsole.log('Welcome! Please answer a few questions.');\nprompt.multi([\n  {\n    key: 'username',\n    label: 'Enter your desired username',\n    default: 'guest_user'\n  },\n  {\n    label: 'Enter your password (min 5 chars)',\n    key: 'password',\n    type: 'password',\n    validate: function (val) {\n      if (val.length < 5) {\n        throw new Error('Password must be at least 5 characters long');\n      }\n    }\n  },\n  {\n    label: 'How many pets do you have?',\n    key: 'pets',\n    type: 'number',\n    default: function () {\n      // Example of dynamic default based on previous input\n      return this.password ? this.password.length : 0;\n    }\n  },\n  {\n    label: 'Do you agree to the terms? (yes/no)',\n    key: 'agree',\n    type: 'boolean'\n  }\n], function (result) {\n  console.log('\\nThank you for your input:');\n  console.log(JSON.stringify(result, null, 2));\n  process.exit(0);\n}, function (err) {\n  console.error('\\nAn error occurred during prompting: ' + err);\n  process.exit(1);\n});","lang":"javascript","description":"This quickstart demonstrates how to use `prompt.multi` to collect several types of user input, including text with a default, a password with validation, a number, and a boolean."},"warnings":[{"fix":"Migrate to actively maintained CLI prompt libraries like 'inquirer', '@clack/prompts', or 'prompts' for modern features, security, and ongoing support.","message":"This package is effectively abandoned, with its last update over a decade ago. It does not receive security patches, bug fixes, or new feature development. Using it in production environments is not recommended due to potential unpatched vulnerabilities and lack of modern JavaScript support.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"If using ESM, you must either rewrite your application to use CommonJS or use a dynamic `import()` statement with caution: `import('cli-prompt').then(cliPrompt => cliPrompt.prompt(...));`. Alternatively, migrate to an ESM-compatible prompting library.","message":"The package is CommonJS-only and relies on `require()`. It will not work directly in ES Module (ESM) environments without a bundler or compatibility layer. Attempting to `import` it will result in an error like 'require is not defined' or 'ERR_REQUIRE_ESM'.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Wrap `prompt` calls in a Promise manually or switch to a modern prompt library that supports Promises natively for cleaner async code.","message":"The `prompt` functions are callback-based and do not return Promises. This makes them incompatible with modern async/await patterns without manual Promise wrapping. The API is entirely synchronous in its execution flow, handling input via callbacks.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Always provide an `onError` callback to handle cases where STDIN is unavailable or ends prematurely, especially when running in automated scripts or non-interactive environments. Ensure your application manages the STDIN stream appropriately.","message":"cli-prompt will not work if STDIN has already ended. If `onError` is not provided, this condition might lead to uncaught errors or silent failures in non-interactive environments.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"This package is CommonJS-only. Either switch your project to CommonJS, use dynamic `import('cli-prompt')` (if feasible), or migrate to a modern, ESM-compatible CLI prompting library.","cause":"Attempting to use `require('cli-prompt')` in an ES Module (ESM) context.","error":"ReferenceError: require is not defined"},{"fix":"Ensure the application is run in an interactive terminal. Provide an `onError` callback to handle this gracefully, or check `process.stdin.isTTY` before attempting to prompt.","cause":"The `cli-prompt` library attempted to read input from `stdin`, but the input stream was already closed or not available (e.g., in a non-interactive script or piped input).","error":"Error: STDIN has ended"},{"fix":"The user input for the password did not satisfy the validation rules. Correct the input or adjust the `validate` function logic if the rules are too strict.","cause":"Custom validation function for a `password` type in `prompt.multi` threw an error because the input did not meet the specified length requirement.","error":"Error: password must be at least 5 characters long"}],"ecosystem":"npm","meta_description":null}