Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including childprocess-messageport with all npm packages installed. Try it out:

var childprocessMessageport = require("childprocess-messageport")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

childprocess-messageport v1.0.0

Turns ChildProcess IPC into MessagePort


npm version Build Status

Turns ChildProcess IPC into MessagePort.


Instead of learning/using different API for different communication channels, we should unite them into a single interface pattern, either MessagePort or WebSocket.

How to use

const childProcess = ChildProcess.fork('echo.js');
const messagePort = new ChildProcessMessagePort(childProcess);

messagePort.onmessage = event => {
  // Could be either a string or Buffer

messagePort.postMessage('Hello, World!');

Instead of subscribing to onmessage, you can also subscribe using on('message', handler).

If the underlying childProcess.send is failed, an error event will be emitted.


Like us? Star us.

Want to make it better? File us an issue.

Don't like something you see? Submit a pull request.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free