I am looking for looping program continuously, but the problem looks like the program run without waiting for user make an input
const inquirer = require('inquirer');
const questions = [{
type: 'input',
name: 'name',
message: "What's your name"
}];
do {
inquirer.prompt(questions).then(answers => {
console.log(`Hi, ${answers['name']}`);
});
} while (true);
Simple way to wait for user input is to use async/await. First you need to wrap block into self executing async function and then use await to get user response.
const inquirer = require('inquirer');
const questions = [{
type: 'input',
name: 'name',
message: "What's your name"
}];
(async () => {
do {
const answers = await inquirer.prompt(questions);
console.log(`Hi, ${answers['name']}`);
} while (true);
})();