Putting my comment into answer as requested...
I don't think what you ask for exists.
You could start a generic node.js app that was already on disk where that app is coded to get its code from stdinput and then you could feed your code to stdinput for the stub app to read. No extra reads or writes of your code that way.
Here's an example of two simple apps that do this:
First, the app that just reads from stdin and executes it as Javascript:
// read-from-stdin.js let input = ""; process.stdin.on('data', function(chunk) { input += chunk; }); process.stdin.on('end', function() { eval(input); }); process.stdin.on('error', function(err) { console.log("err:", err); });
Then, an app that launches that app and passes it some JS to execute:
const spawn = require('child_process').spawn; let child = spawn('node', ['read-from-stdin.js'], {stdio: ['pipe', 'inherit', 'inherit']}); child.on('error', function(err) { console.log("err on spawn ", err); }); child.stdin.write("console.log('Hello from your parent')"); child.stdin.end();
When I run the second code, it launches the first code and sends it a console.log() statement via stdin which the code in the first app reads from stdin and then executes.