gpt4 book ai didi

node.js - createInterface 在终端中打印两次

转载 作者:搜寻专家 更新时间:2023-10-31 22:16:50 24 4
gpt4 key购买 nike

当使用 readline 接口(interface)时,从 stdin 到 stdout 的所有内容都会打印两次:

var rl = require('readline');
var i = rl.createInterface(process.stdin, process.stdout);

当我运行这段代码时,我在终端中输入的所有内容都会被复制。输入“hello world”会产生:

hheelloo  wwoorrlldd

我想这样做是有道理的,因为 readline 模块旨在将输入通过管道传递到输出。但它不也意味着用于创建命令行界面吗?我对我应该如何使用它感到困惑。帮忙?

最佳答案

尝试使用 terminal: false:

var readline = require("readline");
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
});

关于node.js - createInterface 在终端中打印两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24661774/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com