0

I am trying to get the output of the command npm install and show it in my cli module.

But I am getting only the result at the end, not the loading output with the progress bar.

Is maybe npm outputing in another place different from stdout and stderr?

This is my code in Typescript

import * as cp from 'child_process';

const child = cp.spawn('npm', ['install', 'some-module']);
    
child.stdout.setEncoding('utf8');
child.stdout.on('data', (chunk) => {
    process.stdout.write(chunk);
});
    
child.stderr.setEncoding('utf8');
child.stderr.on('data', (chunk) => {
    process.stdout.write(chunk);
});

This is the only output I get at the end of the process:

added 154 packages, and audited 505 packages in 52s

Where the loading bar and all the rest of the output go? Why it is not in stdout or stderr?

ndr4
  • 107
  • 8

0 Answers0