Executing files or commands with Child Processes
suggest changeSyntax
- child_process.exec(command[, options][, callback])
- child_process.execFile(file[, args][, options][, callback])
- child_process.fork(modulePath[, args][, options])
- child_process.spawn(command[, args][, options])
- child_process.execFileSync(file[, args][, options])
- child_process.execSync(command[, options])
- child_process.spawnSync(command[, args][, options])
Remarks
exec, execFile, fork, and spawn return a ChildProcess. execSync and execFileSync return the command's stdout, and they throw if the command fails. spawnSync returns a result object (status, stdout, stderr, and so on). A non-zero exit does not throw from spawnSync unless you check status yourself. A failure to start the process still throws.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents