Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ndelangen opened this issue Dec 21, 2016 · 0 comments

Comments

@ndelangen
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant