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

178
Vistas
How to answer a CLI question using exec from child_process in NodeJs

I have a problem where I run a script in NodeJs, in this script I have an exec function which calls a CLI program, that CLI program requires two other answers after that command, but I don't know how I can answer this when I exec this from child_process so the command will be forever waiting for these answers.

Here is an example, just keep in mind where I have the command npm init, it will be the CLI program I am using instead, I know with npm I could pass some flag like -y and it will work for the answers, but I don't have this feature in the CLI program:

import { exec } from 'child_process';
import { promisify } from 'util';

const execFunction = promisify(exec);

const { stdout } = await execFunction(`npm init`);

console.log('stdout', stdout);
about 4 years ago · Juan Pablo Isaza
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