Terminal one
node server.js14.x · Node.js 22.13+
Create a Node.js server and client on one machine. Rust has a separate native guide with the same normal framed event contract.
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 newernpm install --save-exact node-ipc@14.0.0These examples describe the 14.x Node.js package. Pin the exact numeric release rather than a mutable tag or version range.
server.jsimport 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();client.jsimport 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');
});
});node server.jsnode client.jsThe client prints hello world!, disconnects, and leaves the server ready for the next client.
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;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.