Questions tagged [inquirerjs]

Use this tag for questions related to the Inquirer JavaScript package, which provides a command line interface for Node.js.

The Documentation section of the package's GitHub README provides examples of usage, as well as links to various plugins.

67 questions
8
votes
2 answers

How to write unit tests for Inquirer.js?

I was wondering how to write unit tests for the npm package Inquirer.js, which is a tool to make CLI package more easily. I have read this post but I was't able to make it works. Here is my code that needs to be tested: const questions = [ …
Oscar
  • 1,071
  • 13
  • 26
7
votes
2 answers

How do I dynamically add questions to Inquirer JS during execution, using rxjs?

I want to ask questions to the user without having all the questions lined up immediately. The documentation mentions rxjs but I feel there is a gap in the documentation on how to properly add questions while prompts are being executed, or at least…
William Bernting
  • 561
  • 4
  • 15
6
votes
1 answer

How do I register an inquirer.js plugin for a yeoman generator prompt?

When authoring a yeoman generator, I'd like to use the 'autocomplete' plugin for inquirer (https://github.com/mokkabonna/inquirer-autocomplete-prompt) in one of my prompts. I can't seem to find anything in the docs that says how to register this…
Ben
  • 16,124
  • 22
  • 77
  • 122
5
votes
2 answers

How to clear wrong input in Inquirer.js

const inquirer = require("inquirer") var questions = [ { type: "number", name: "name", message: "Please the number of players", validate: function (name) { var valid = Number.isInteger(name) return valid || `Please…
Shah
  • 75
  • 1
  • 5
3
votes
3 answers

how to call another page function name in inquirer node js

I am making a CLI using inquirer in nodejs. So in Every choice list I have to give Exit choice so if user want to exit he/she can easily Exit. So I have to write Exit again and again to avoid that problem I made a Exit.js file and move Exit code…
user16041868
3
votes
1 answer

Send a string and Enter key to a Node.js script from command line

I am running a Node.js script in Linux that prompts (via lib) user for a code. I get the process id of the script: pgrep -f test.js and then pass it the code with a new line to simulate Enter key: echo -e "1234\n" > /proc/88888/fd/0 The code 1234…
Haris ur Rehman
  • 2,593
  • 30
  • 41
3
votes
0 answers

How To Debug Node CLI (Interactive Prompts with Inquirer) With VS Code?

I have a Node CLI built with Commander and Inquirer. I'm currently trying to debug the application using VS Code. My current launch.json configuration: { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions…
StephenWeiss
  • 873
  • 1
  • 8
  • 17
3
votes
0 answers

Using node-inspect with inquirer

I am trying to use node-inspect to debug an application that uses inquirer. If I run: node app.js I get asked the first question for my app. I then use the keyboard to enter my answer and hit enter to continue. My issue is when Run node-inspect…
Ian Jamieson
  • 4,376
  • 2
  • 35
  • 55
2
votes
1 answer

ReferenceError: require is not defined in ES module

I'm trying to use the command node index.js within the terminal to bring up the prompts I made and keep running into several errors, I looked them up on here seemingly fixed it and got another error. Maybe someone can point it out so I can save some…
user20071967
2
votes
1 answer

Inquirer.js, change symbol at the beginning of question?

By default inquirer js questions are preceded by a '?'. Is it possible to change it to something else? I tried exploring but did not find it mentioned anywhere.
Legolas
  • 105
  • 8
2
votes
1 answer

Running several Axios requests in parallel to validate data

I'm using Inquirer.js to interact with a user. In one of the dialogs, the user can specify a comma-separated list of "items". The following validation function checks against an API, whether the "item" is available. If not, the user is prompted to…
idleberg
  • 12,634
  • 7
  • 43
  • 70
1
vote
1 answer

Repetitive prompting with validation in Inquirer.js when using a validation function featuring fetch

In the context of Inquirer.js, one of my question-prompts involves a validation function to check if the user-supplied Github username exists. This validation function uses an fetch function in order to check if the Github username exits. The…
shau
  • 15
  • 4
1
vote
0 answers

Getting UNDEFINED when trying to render my index.html

I cannot get my function generatePage to display all the data collected from my prompts. I keep getting undefined as return when the page is rendered. I already made some changes and change some values and it still doesn't go through, any help is…
1
vote
1 answer

Error: Debug Failure. False expression: Non-string value passed to `ts.resolveTypeReferenceDirective`,

I don't know why am I getting the following error which say: Error: Debug Failure. False expression: Non-string value passed to `ts.resolveTypeReferenceDirective`, likely by a wrapping package working with an outdated…
crispengari
  • 7,901
  • 7
  • 45
  • 53
1
vote
0 answers

Pipe output of an interactive script in shell

I have a large Node repo with many npm scripts to manage the project. I created an interactive script with Inquirer.js to act as an entry point to help developers to navigate. The script outputs the result in JSON. To pick the selected npm script,…
miklosme
  • 761
  • 1
  • 5
  • 19
1
2 3 4 5