Bird
0
0

Identify the error in this code snippet:

medium📝 Debug Q6 of 15
Node.js - Child Processes
Identify the error in this code snippet:
const { fork } = require('child_process');
const child = fork();
child.send('Hi');
Achild process must be awaited before sending messages
Bsend method does not exist on child process
Cfork requires a file path argument; missing here
Dfork cannot be called without new keyword
Step-by-Step Solution
Solution:
  1. Step 1: Check fork usage

    fork requires a file path argument to run; calling fork() without arguments is invalid.

  2. Step 2: Verify other options

    send exists on child process, fork is a function not a class, no need to await fork.

  3. Final Answer:

    fork requires a file path argument; missing here -> Option C
  4. Quick Check:

    fork argument required [OK]

Quick Trick: Always provide a file path to fork() [OK]
Common Mistakes:
  • Calling fork without file argument
  • Thinking send method is missing
  • Using new keyword with fork

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Node.js Quizzes