14.x · Node.js 22.13+

Send the first local message

Create a Node.js server and client on one machine. Rust has a separate native guide with the same normal framed event contract.

1. Confirm the runtime

Version 14 uses native ES modules in Node.js only.

Use Node.js 22.13 or newer. The node-ipc JavaScript package does not run in web browsers, whether bundled or unbundled. “Native ESM” means Node.js ESM without a transpiler, not native browser ESM. Version 12 remains a separate legacy line for older Node runtimes.

node --version
# v22.13.0 or newer

2. Pin the release

npm install --save-exact node-ipc@14.0.0

These examples describe the 14.x Node.js package. Pin the exact numeric release rather than a mutable tag or version range.

3. Create server.js

import ipc from 'node-ipc';

ipc.config.id = 'world';
ipc.config.silent = true;
ipc.config.parser = 'fast';

ipc.serve(() => {
  ipc.server.on('app.message', (data, socket) => {
    ipc.server.emit(socket, 'app.message', {
      from: ipc.config.id,
      message: `${data.message} world!`
    });
  });
});

ipc.server.start();

4. Create client.js

import ipc from 'node-ipc';

ipc.config.id = 'hello';
ipc.config.silent = true;
ipc.config.parser = 'fast';

ipc.connectTo('world', () => {
  ipc.of.world.on('connect', () => {
    ipc.of.world.emit('app.message', {message: 'hello'});
  });

  ipc.of.world.on('app.message', data => {
    console.log(data.message); // hello world!
    ipc.disconnect('world');
  });
});

5. Run both processes

Terminal one

node server.js

Terminal two

node client.js
Expected output

The client prints hello world!, disconnects, and leaves the server ready for the next client.

14.x CommonJS loading

On Node.js 22.13+, the native ESM entry point can also be loaded synchronously. Version 14 does not generate a separate transpiled CommonJS bundle.

const ipc = require('node-ipc').default;

Choose controls before production

This trusted local example uses the default Fast profile. Use Guarded for bounded framing and event-name controls, or Assured with mutually authenticated TLS and an event allow-list on a hostile network.