(Firstly, does ls
actually exist on windows?)
I had a similar issue spawning child processes a little while back and it took me ages to figure out the correct way of doing it.
Here's some example code:
var spawn = require('child_process').spawn;
var cp = spawn(process.env.comspec, ['/c', 'command', '-arg1', '-arg2']);
cp.stdout.on("data", function(data) {
console.log(data.toString());
});
cp.stderr.on("data", function(data) {
console.error(data.toString());
});
Have a look at this ticket for an explanation of the issue: https://github.com/joyent/node/issues/2318