Node.js module

child_process

The 'node:child_process' module enables spawning and controlling subprocesses from Node.js. It supports synchronous and asynchronous execution via exec, execFile, spawn, and fork functions.

Child processes can inherit stdio, communicate via IPC channels, and return exit codes. This module is essential for leveraging external commands, implementing parallel work, and managing worker processes.

Works in Bun · notes

Core functionality works. The Stream class is not exported. IPC cannot send socket handles between processes; Node.js <> Bun IPC can be used with JSON serialization. Some process properties are missing.

Functions 7

  • child_process.exec()

    Spawns a shell then executes the command within that shell, buffering any generated output.

  • child_process.execFile()

    The child_process.execFile() function is similar to exec except that it does not spawn a shell by default.

  • child_process.execFileSync()

    The child_process.execFileSync() method is generally identical to execFile with the exception that the method will not return until the child process has fully closed.

  • child_process.execSync()

    The child_process.execSync() method is generally identical to exec with the exception that the method will not return until the child process has fully closed.

  • child_process.fork()

    The child_process.fork() method is a special case of spawn used specifically to spawn new Node.js processes.

  • child_process.spawn()

    The child_process.spawn() method spawns a new process using the given command, with command-line arguments in args.

  • child_process.spawnSync()

    The child_process.spawnSync() method is generally identical to spawn with the exception that the function will not return until the child process has fully closed.

Classes 1

Interfaces 32

Types 8

Namespaces 2