To be able to send messages you must use fork instead of spawn
The child_process.fork () method is used specifically for spawn new Node.js processes. Like child_process.spawn (), a ChildProcess object is returned. The child process will be a communication channel. See subprocess.send () for details.
So in the end it will be like this:
// master.js 'use strict'; const path = require('path'); const { fork } = require('child_process'); const prcs = fork(path.join(__dirname, './slave.js')); prcs.on('message', msg => { console.log('SLAVE is saying:', msg); }); prcs.send('DO IT!!!'); // slave.js 'use strict'; process.on('message', msg => { console.log('PARENT is saying:', msg); }); setTimeout(() => { process.send('Let me free please'); process.exit(0); }, 1000);