I've made an node.js app to list all .txt files from a directory recursively and, for each one, do some stuff.
Here's my app.js:
var spawn = require('child_process').spawn,
    dir = spawn('dir', ['*.txt', '/b']);
dir.stdout.on('data', function (data) {
    //do some stuff with each stdout line...
    console.log('stdout: ' + data);
});
dir.stderr.on('data', function (data) {
    //throw errors
    console.log('stderr: ' + data);
});
dir.on('close', function (code) {
    console.log('child process exited with code ' + code);
});
When I run node app.js via console, I get the error message below:
events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: spawn ENOENT
    at errnoException (child_process.js:980:11)
    at Process.ChildProcess._handle.onexit (child_process.js:771:34)
I'm using node v0.10.13 at win32 environment. 
I do this way (spawn) because I want to handle stdout line by line (the exec method release entire stdout as one string).
* UPDATE *
By the way, using
spawnforchild_processdoes not guarantee that the output forcmd dirwill be line by line. I've created a question for that too.