Friday, March 28, 2014

Would understanding streams help avoid errors with Readline?

When I try to run this: var readline = require('readline'); var rl = readline.createInterface({ input: process.sdtin, output: process.stdout, }); rl.question("What do you think of node.js?", function(answer) { // TODO: Log the answer in a database console.log(answer + ',Thank you for your valuable feedback.'); // These two lines together allow the program to terminate. Without // them, it would run forever. i.close(); process.stdin.destroy(); }); I get this: readline.js:833 if (stream._keypressDecoder) return; ^ TypeError: Cannot read property '_keypressDecoder' of undefined at Object.emitKeypressEvents (readline.js:833:13) at new Interface (readline.js:118:13) at Object.exports.createInterface (readline.js:39:10) at Object. (/home/shambaughlab/node_examples/seh1_readline.js:3:19) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) I am unsure, but maybe I should look at streams.

No comments:

Post a Comment