我遇到了以下使用keypress模块的node.js代码。 https://www.npmjs.com/package/keypress
var keypress = require('keypress');
// make `process.stdin` begin emitting "keypress" events
keypress(process.stdin);
// listen for the "keypress" event
process.stdin.on('keypress', function (ch, key) {
console.log('got "keypress"', key);
if (key && key.ctrl && key.name == 'c') {
process.stdin.pause();
}
});
process.stdin.setRawMode(true);
process.stdin.resume();
它在命令行中运行良好。但是,当我在调试模式下在Webstorm上运行它时,我收到错误
process.stdin.setRawMode(true);
^
TypeError: process.stdin.setRawMode is not a function
为什么会这样?