linuxdan linuxdan - 3 months ago 15
Node.js Question

How to get output from node exec when running `npm install`?

I'm running the following:

const exec = require('child_process').exec;
let installProcess = exec('npm install');
installProcess.stdout.pipe(process.stdout);
installProcess.stderr.pipe(process.stderr);


But I get no output in my terminal, what else can I try?

Answer

The following ended up working for me:

const execSync = require('child_process');
execSync('npm install', {stdio:[0,1,2]});