Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

88
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda