Skip to content

How to enable ipc communication : enable process.send() & child.on('message') ? #183

Open
@ndelangen

Description

@ndelangen

I'd like to be able to communicate with the child process : send / receive data.

Using node's require('child_process').spawn I am able to do this:

const child = spawn('script.js', [], {
  detached: false,
  stdio: [null, null, null, 'ipc']
});

child.on('message', data => console.log(data));

script.js

process.send('Hello World');

When I use require('pty.js').spawn instead of require('child_process').spawn this fails:

process.send('📡');
        ^
TypeError: process.send is not a function
    at Object.<anonymous> (/Users/.../.../script.js:46:9)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:420:7)
    at startup (bootstrap_node.js:139:9)
    at bootstrap_node.js:535:3

Am I trying something that's impossible?
Am I missing a configuration option? If so, how do I enable / use this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions