Если запустить repl из файла:
// repl.js
const repl = require('repl');
repl.start();
то можно с помощью
.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)