'readline createInterface is not a function when run client-side

Issue using readline

Setup

  • I am trying to use 'readline' package in a client-side dev setup, using watchify targeting a bundle.js file and python to create a server.
  • The module works fine with node.js but fails to work in this dev setup.

"TypeError: readline.createInterface is not a function"

const rl = require("readline")
// const readline = rl.default
const ui = rl.createInterface({
  input: process.stdin,
  output: process.stdout,
});

I found one solution in another stackoverflow post for readline-promise, (and in an issue log for the repo) claiming the problem could be avoided by explicitly targeting the default entry point (?). Doesn't work for me here however!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source