Stats

273 Contributors: 1 Friday, August 5, 2016
Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Rip Tutorial: riptutorial@gmail.com
Roadmap: roadmap

Executing files or commands with Child Processes

Syntax

  • 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

When dealing with child processes, all of the asynchronous methods will return an instance of ChildProcess, while all the synchronous versions will return the output of whatever was run. Like other synchronous operations in Node.js, if an error occurs, it will throw.

Related Examples