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

176
Views
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
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!