Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calling repl.start() causes a doubling of stdin/stdout #2107

Open
natemwilson opened this issue Feb 20, 2024 · 0 comments
Open

calling repl.start() causes a doubling of stdin/stdout #2107

natemwilson opened this issue Feb 20, 2024 · 0 comments

Comments

@natemwilson
Copy link

Search Terms

repl
repl.start()
context
double
STDIN
STDOUT

Expected Behavior

STDOUT is not double printed

Actual Behavior

STDOUT is double printed

Steps to reproduce the problem

I want a ts-node repl, with all its benefits, with context from my app attached, (note I would in reality attach an imported module, but here am just attaching a variable to illustrate my need minimally.) Since I want context attached to my repl, I am using the node built-in package, repl, like so:

example.ts

import repl from "repl";

const foo = "bar";

const replServer = repl.start();

replServer.context.foo = foo;

Maybe this is not best practice, if so, please advise.

If I try to run the script example.ts with ts-node, then type the six characters, f,o,o,b,a,r, I see the following output:

$ npx ts-node  -r ./example.ts
> ffoobbaarr

So the bug is that every input is doubled, as I would expect to only see foobar.

Minimal reproduction

TypeStrong/ts-node-repros#38

Specifications

  • ts-node version: v10.9.2
  • node version: v20.11.0
  • TypeScript version: v5.3.3
  • tsconfig.json, if you're using one:
{}
  • package.json:
{
  "dependencies": {
    "ts-node": "latest",
    "typescript": "latest"
  }
}

  • Operating system and version:
    Mac OSX 13.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant