process.send is conditionally defined in Node.js

Child processes have a process.send method to communicate back with the process that spawned them, while the root process doesn't have any "parent" to communicate, so its not there. From the docs:

In the child the process object will have a send() method, and process will emit objects each time it receives a message on its channel.

To avoid having to "litter the code with conditionals", a temporary solution might be to just put a "noop" function in its place at the top of any "root" files you might be spawning processes from:

process.send = process.send || function () {};

Tags:

Node.Js