Nodejs question of type input with npm inquirer not working

0 votes

This is my first time using npm inquirer.

I'm using a code that looks like this:

const inquirer = require("inquirer");

const questions = [
  {
    type: "checkbox",
    name: "collections.telemetria",
    message: "Select collections of database telemetria",
    choices: [
      "chimera-11/14/2019,-4:22:38-PM",
      "chimera-11/14/2019,-4:28:26-PM"
    ]
  },
  {
    type: "checkbox",
    name: "collections.testa",
    message: "Select collections of database testa",
    choices: ["testa_c"]
  }
];

async function main() {
  const collections = (await inquirer.prompt(questions)).collections;
  console.log("collections:", collections);
  const outPath = await inquirer.prompt([
    {
      type: "input",
      name: "outPath",
      default: "./",
      message: "Insert the output path"
    }
  ]).outPath;
  console.log(outPath);
}
main();

The issue is that when it comes to answering the type input question, the phrase undefined shows, and I am unable to provide any input.

image

Here is a code sandbox: https://codesandbox.io/s/stoic-kowalevski-dgg5u

Jun 7, 2022 in Node-js by Vaani
• 7,070 points
1,863 views

1 answer to this question.

0 votes

The right code should be:

const outPath = (await inquirer.prompt([
    {
      type: "input",
      name: "outPath",
      default: "./",
      message: "Insert the output path"
    }
  ])).outPath;
  console.log(outPath);
answered Jun 7, 2022 by Neha
• 9,020 points

Related Questions In Node-js

0 votes
0 answers

npm command not working after installing nodejs in windows10?

i have installed nodejs from nodejs website. ...READ MORE

Aug 11, 2022 in Node-js by Neha
• 9,020 points
1,523 views
0 votes
1 answer

Error:nvm is not compatible with the npm config "prefix" option:

Hello @kartik, After installing nvm using brew, create ~/.nvm directory: $ ...READ MORE

answered Jul 15, 2020 in Node-js by Niroj
• 82,880 points
4,756 views
0 votes
1 answer

Error:npm not working after clearing cache

Hello @kartik, Try this: npm cache clean --force OR It ...READ MORE

answered Jul 17, 2020 in Node-js by Niroj
• 82,880 points
6,495 views
0 votes
0 answers
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,901 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,428 views
+1 vote
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured ...READ MORE

answered Aug 6, 2018 in Blockchain by aryya
• 7,460 points
1,391 views
0 votes
1 answer

What version of npm works with nodejs 0.10?

Here's the complete list (between v0.10.0 - ...READ MORE

answered Jun 9, 2022 in Node-js by Neha
• 9,020 points
2,306 views
0 votes
1 answer

NodeJS express get request is not working on mobile

For your API call, try to add ...READ MORE

answered Jun 7, 2022 in Node-js by Neha
• 9,020 points
1,912 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP