What is the correct syntax to spawn a process in Node.js?
Question
I'm trying to follow along with
http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options
In an effort to do
./node_modules/.bin/mocha --reporter json -u tdd
I have tried
var mocha = spawn('./node_modules/.bin/mocha', ['--reporter json -u tdd']);
But I get the following error
error: unknown option `--reporter json -u tdd'
What am I doing wrong?
Solution
Looking quickly at the reference URL you provided, it seems that your bracketed arguments need to be separate:
var mocha = spawn('./node_modules/.bin/mocha', ['--reporter','json','-u','tdd']);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow