Child Process

Node.js child_process module — spawn child processes.

Provides synchronous and asynchronous methods for creating child processes. Sync methods (execSync, execFileSync, spawnSync) block the event loop and are commonly used in build scripts and CLI tooling. Async methods (exec, execFile, spawn, fork) return ChildProcess EventEmitter objects with streaming stdout/stderr via the event loop.

Module: node:child_process Support: Experimental Since: 1.1.0 Docs: Node.js Docs

7 members: 7 undocumented

Static Methods

⚪ execSync(command, options)
Synchronously executes a command in a shell and returns the stdout output.
⚪ execFileSync(file, args, options)
Synchronously executes a file without a shell and returns the stdout output.
⚪ spawnSync(command, args, options)
Synchronously spawns a child process and returns a detailed result object.
⚪ exec(command, options, callback)
Asynchronously executes a command in a shell.
⚪ execFile(file, args, options, callback)
Asynchronously executes a file without a shell.
⚪ spawn(command, args, options)
Signal that terminated the child process, or null.
⚪ fork(modulePath, args, options)
Spawns a new Node.js process using the given module path.

Dictionary SpawnSyncResult

Result object returned by spawnSync().

Since: 1.1.0 Docs: Node.js Docs

7 members: 7 undocumented

Properties

⚪ pid
Process ID of the child.
⚪ output
Process ID of the child.
⚪ stdout
Stdout output (Buffer or string depending on encoding option).
⚪ stderr
Stderr output (Buffer or string depending on encoding option).
⚪ status
Exit code of the child process, or null if terminated by signal.
⚪ signal
Stderr output (Buffer or string depending on encoding option).
⚪ error
Error object if the child failed to spawn.

---