I want to take the output of a c++ program and input it into the stdin of a javascript file. However I have been unable to push anything into the stdin using the method...
node example.js < test.txt
because I get the following errors.
example.js:35
stdin.setRawMode( true );
TypeError: undefined is not a function
at Object. (example.js:35:7)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
The offending code appears to be as below. It works fine during normal input, however crashes in the above scenario.
var stdin = process.stdin;
stdin.setRawMode( true );
stdin.resume();
stdin.setEncoding( 'utf8' );
stdin.on( 'data', function( key ){
//do stuff based upon input
Has anyone encountered this, or any ideas about how to fix it? Or another way of going about this problem?