// Yeah, Jetty!
var Jetty = require("jetty");
// Create a new Jetty object. This is a through stream with some additional
// methods on it. Additionally, connect it to process.stdout
var jetty = new Jetty(process.stdout);
// Clear the screen
jetty.clear();
// write something
jetty.text("hello world");
jetty.moveTo([0,0]);
jetty.text("hello panda");
在其他问题中,@michelek 的回答起到了作用。但是,当您开始使用它时,当输出被重定向到一个文件时,或者当您在调试器中或在 linux 屏幕会话中运行时,您可能会遇到 Exception 问题,等等。您可能会看到诸如 process.stdout.clearLine is not a function之类的消息。
if (process.stdout.isTTY) {
process.stdout.write("Hello, World");
process.stdout.clearLine(0);
process.stdout.cursorTo(0);
process.stdout.write("\n"); // end the line
}