0

I tried to make a simple cli nodejs game, with inquirer to ask for player input - name and question answers.

I wrote the following code, which works as expected:

async function askName() {
    playerName = (await inquirer.prompt({
        name: 'player_name',
        type: 'input',
        message: 'What is your name?',
        default() {
            return 'Player';
        },
    })).player_name;
}

But this code does not work and my debugger won't go into it:

async function acceptAnswer() {
    await inquirer.prompt({
        name: 'player_name',
        type: 'input',
        message: 'What is your answer',
        validate(text) {
            if (/^[\u05D0-\u05EA]{5}$/.test(text)) // check if the input is a five letter word in Hebrew
                return true;
            console.log(chalk.red("Please try again"));
            return false;
        },
    });
}

(I check, and chalk isn't the problem).

I run JetBrains Webstorm on windows 21H2 with nodejs 16.13.2 and npm 8.1.2 Any help appreciated!

  • I haven't `chalk` installed, so I replaced it with simple `console.log` and everything works perfectly. Could you please paste your errors log (If exists)? – Mostafa Fakhraei Feb 08 '22 at 07:09
  • @trincot oh, my bad. that isn't the issue though - I translated everything from Hebrew for this post (the code is exactly the same on my local machine, except for the strings). Anyway, this isn't the problem and I'll edit the question. – TheBooker66 aka Ethan Feb 08 '22 at 09:29
  • @MostafaFakhraee That's the weird part: I don't get any. Just "Process finished with exit code 1". – TheBooker66 aka Ethan Feb 08 '22 at 09:30

0 Answers0