Windows 上的 Node.Js - 如何清除控制台 [英] Node.Js on windows - How to clear console
问题描述
对 node.js 环境和哲学是全新的,我想回答几个问题.我已经下载了用于 windows 安装程序的 node.js 以及 node 包管理器.Windows Cmd 提示符当前正在用于运行 nodejs 应用程序.
Being totally new into node.js environment and philosophy i would like answers to few questions. I had downloaded the node.js for windows installer and also node package manager.Windows Cmd prompt is being currently used for running nodejs apps.
cls 清除命令窗口或命令提示符中的错误.node.js 是否有等价物?console.clear 不存在 ;( 还是以其他形式存在?
cls clears the command window or errors in command prompt. Is there a equivalent for node.js ? console.clear does not exist ;( or does it in some other form?
我通过下面这段代码创建了一个服务器
I created a server through this code below
var http = require("http");
http.createServer(function (request, response) {
response.writeHead(200, {
"Content-Type": "text/html"
});
response.write("Hello World");
console.log("welcome world")response.end();
}).listen(9000, "127.0.0.1");
我将代码更改为下面并刷新浏览器发现内容类型没有改变,我如何才能看到变化?
i changed the code to below and refreshed the browser to find that content type does not change, how do i get to see the changes?
var http = require("http");
http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
console.log("welcome world")
response.end();
}).listen(9000,"127.0.0.1");
推荐答案
console.log(' 33[2J');
这适用于 linux.不确定 Windows.
This works on linux. Not sure about windows.
您可以使用以下方式欺骗"用户:
You can "trick" the user using something like this:
var lines = process.stdout.getWindowSize()[1];
for(var i = 0; i < lines; i++) {
console.log('
');
}
这篇关于Windows 上的 Node.Js - 如何清除控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!