G
G
goju2017-05-06 00:35:51
JavaScript
goju, 2017-05-06 00:35:51

How to reset NodeJS console?

When teaching, I use the Node.
How to reset the memory without restarting the console?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
alex, 2017-05-06
@goju

If you run repl from a file:

// repl.js
const repl = require('repl');
repl.start();
then you can use.clear
node repl.js
> var a = 5;
undefined
> a
5
> .clear
Clearing context...
> a
ReferenceError: a is not defined
    at repl:1:1
    at ContextifyScript.Script.runInContext (vm.js:32:29)
    at REPLServer.defaultEval (repl.js:342:29)
    at bound (domain.js:280:14)
    at REPLServer.runBound [as eval] (domain.js:293:12)
    at REPLServer.onLine (repl.js:537:10)
    at emitOne (events.js:96:13)
    at REPLServer.emit (events.js:189:7)
    at REPLServer.Interface._onLine (readline.js:238:10)
    at REPLServer.Interface._line (readline.js:582:8)

P
profesor08, 2017-05-06
@profesor08

The first google link leads to an example of clearing the node console: https://gist.github.com/KenanSulayman/4990953
or
process.stdout.write('\033c');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question