Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the correct syntax to spawn a process in Node.js?

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?

like image 557
deltanovember Avatar asked Feb 19 '26 00:02

deltanovember


1 Answers

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']);
like image 150
OrionRogue Avatar answered Feb 21 '26 13:02

OrionRogue



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!