これは私のために働くことになった次完璧
const exec = require('child_process').exec;
const installProcess = exec('npm install --verbose');
installProcess.stdout.on('data', process.stdout.write);
installProcess.stderr.on('data', process.stdout.write);
installProcess.on('close', (code) => process.stdout.write(`exited with ${code}`));
と結果
❯ node index.js
stderr: npm
stderr: info it worked if it ends with ok
npm verb cli [ '/usr/local/Cellar/node/6.3.0/bin/node',
npm verb cli '/usr/local/bin/npm',
npm verb cli 'install',
npm verb cli '--verbose' ]
npm info using [email protected]
npm info using [email protected]
stderr: npm verb
stderr: correctMkdir /Users/bwin/.npm/_locks correctMkdir not in flight; initializing
stderr: npm
stderr: info lifecycle [email protected]~preinstall: [email protected]
stderr: npm verb
stderr: exit [ 0, true ]
stderr: npm info
stderr: ok
exited with 0
はhttp://stackoverflow.com/a/を参照してください。 20643568/2308005 –