在Node.js中生成进程的正确语法是什么?

del*_*ber 2 mocha.js spawn node.js

我正在努力跟随

http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options

努力做到

./node_modules/.bin/mocha --reporter json -u tdd
Run Code Online (Sandbox Code Playgroud)

我试过了

var mocha    = spawn('./node_modules/.bin/mocha', ['--reporter json -u tdd']);
Run Code Online (Sandbox Code Playgroud)

但是我收到以下错误

error: unknown option `--reporter json -u tdd'
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

Ori*_*gue 9

快速查看您提供的参考URL,您的括号中的参数似乎需要分开:

var mocha    = spawn('./node_modules/.bin/mocha', ['--reporter','json','-u','tdd']);
Run Code Online (Sandbox Code Playgroud)