Node.jsExecuting 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