Could we run an external process with Node.js?

Technology CommunityCategory: Node.jsCould we run an external process with Node.js?
VietMX Staff asked 3 years ago

Yes. Child process module enables us to access operating system functionaries or other apps. Scalability is baked into Node and child processes are the key factors to scale our application. You can use child process to run system commands, read large files without blocking event loop, decompose the application into various “nodes” (That’s why it’s called Node).

Child process module has following three major ways to create child processes –

  • spawn – child_process.spawn launches a new process with a given command.
  • exec – child_process.exec method runs a command in a shell/console and buffers the output.
  • fork – The child_process.fork method is a special case of the spawn() to create child processes.