ts-node-dev binds to stdin via readline by default

Update,
This issue has been fixed in fbe1eaf and should reach NPM fairly soon as well. The original post is preserved below for historical context.


ts-node-dev is a handy drop in replacement for node-dev that adds Typescript support.
However, somewhat unexpectedly it binds to stdin by default out of the box:

// Read for "rs" from command line  
if (opts.rs !== false) {
  const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
    terminal: false
  })
  rl.on('line', ...);
}

The binding is used to restart the server on demand, as opposed to restarting automatically on changes. While this can be handy, the behavior is currently undocumented and not an intuitive default.

The default setup will result in unexpected behavior when you try to read lines from stdin in your application code: two listeners are reading the stream, whereas you only defined one in your code.

The binding can be disabled by specifying --rs false:

{
  "scripts": {
    "serve": "ts-node-dev --respawn --rs false index.ts"
  }
}