Node.Js on windows - How to clear console

前端 未结 19 1490
迷失自我
迷失自我 2020-12-02 08:51

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 man

19条回答
  •  一生所求
    2020-12-02 09:31

    Based on sanatgersappa's answer and some other info I found, here's what I've come up with:

    function clear() {
        var stdout = "";
    
        if (process.platform.indexOf("win") != 0) {
            stdout += "\033[2J";
        } else {
            var lines = process.stdout.getWindowSize()[1];
    
            for (var i=0; i

    To make things easier, I've released this as an npm package called cli-clear.

提交回复
热议问题