0
我想在窗口上產生子進程來打開終端(cmd.exe)。我得到了一切工作,除了我無法將數據從子進程傳輸到父進程。我想在父進程中訪問終端的輸出。這裏是我的代碼:Node.js - 帶spawn的子進程:無法從子進程流數據
var spawn = require('child_process').spawn;
var child = spawn('cmd', [ '/c', 'start'], {
cwd: '{path-to-folder}'
});
child.stdout.on('data', function (data) {
console.log(data);
});
child.stderr.on('data', function (data) {
console.log(data);
});
child.on('close', function() {
console.log('close');
})
我真的被卡住了,所以任何幫助或tipp將是真棒!提前致謝!