Node.js
/Advanced
Child Processes
Definition
A core Node.js module that provides the ability to spawn new OS processes, execute shell commands, and communicate with them.
Explain Like I'm New
Sometimes you need Node to do something outside of JavaScript, like running a Python script, executing a bash command (`ls -la`), or starting a separate heavy Node script. The `child_process` module lets Node act like a terminal user, typing commands and reading the output.
Real World Example
You build a web interface that converts videos. When the user clicks 'Convert', your Node server uses `exec()` to run the command-line tool `FFmpeg` in the background, converting the video without freezing the web server.
Common Use Cases
- •Executing system commands
- •Running Python/Bash scripts from Node
- •Parallel processing
Interactive Example
Loading...
Console output will appear here...
Interview Questions
basic
- What module do you require to use child processes?
intermediate
- What is the difference between `exec` and `spawn`?