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

89
Views
Problems with exiting from CLI

I've created simple CLI using inquirer and child_process. And i have problem, when i'am closing process with CTLR+C, it seems like its still running process, because terminal not responding anything. And i have to close terminal every time and open it again, it's uncomfortable for me. What i need to do, to exit all processes with simple CTRL+C command? Searched so many solutions in google, but no result. Hope somebody can help me with it

const inquirer = require('inquirer')
const { execSync } = require('child_process')
const { readdirSync } = require('fs')

const targetFolder = './src/pages'

const directories = readdirSync(targetFolder)

const questions = [
    {
        type: 'list',
        name: 'page',
        message: 'Choose page to compile',
        choices: directories,
    },
]

inquirer.prompt(questions).then(({ page }) => {
    const options = {
        stdio: 'inherit',
    }
    execSync(`npm run start -- --env page=${page}`, options)
})
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you use async functions or promises, you have to terminate the program with process.exit(). Add it after execSync into the then call.

about 4 years ago · Juan Pablo Isaza Report
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!