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 in Node-js by Vaani
• 7,020 points
129 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 by Neha
• 8,740 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

6 days ago in Node-js by Neha
• 8,740 points
6 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,740 points
2,392 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,740 points
4,387 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,008 views
0 votes
1 answer
0 votes
1 answer

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

yes all are over TCP/IP connections secured by TLS encryption in hashgraph architecture-hashgraph, ...READ MORE

answered Aug 6, 2018 in Blockchain by aryya
• 7,440 points
650 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 in Node-js by Neha
• 8,740 points
49 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 in Node-js by Neha
• 8,740 points
88 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP