Perfomance & ScalingLesson 86Free preview
Child Process Module
This lesson is part of Node.js · All levels
Summary
This lesson describes the child_process module for running external processes from Node.js, such as shell commands or other programs. You'll use spawn, exec, execFile, and fork to understand the difference between buffer, shell, and communication. This module is useful for running external tools, FFmpeg, or system scripts.
Key points
- Spawn: shellless, stream stdout/stderr, suitable for large programs.
- Exec: running through the shell, the results are collected to the buffer (there is a maxBuffer limit).
- ExecFile: like exec but directly to the file, without shell (more secure).
- The fork makes a special Node.js child process with the IPC channel (send/on 'message').
- Always handle event error and close; don't assume the command always succeeds.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.