Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

260
Views
Javascript Inquirer (npm package) promt quits with exit code one only in one place in the program

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!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!