In languages like Clojure
and Scheme
I do really enjoy writing code in REPL-driven mode, when you write a piece of code in an editor (Emacs
in my case), send it to your REPL, play with it then go back to an editor, fix found issues and send code to REPL again.
I tried to do the same with Node.js
, and it kind of works if I limit myself to usage of ES5
syntax only. But if I use ES6
features like const
, let
and class
, I expectedly get errors on re-evaluation of my declarations:
> let foo = 1;
> let foo = 2;
TypeError: Identifier 'foo' has already been declared
Is there any Node.js REPL
params, or maybe patched REPLs
, or even some magical Emacs
mode which will purge existing declarations when I re-evaluate my code? So that I will be able to write Node.js
code this way without the need to constantly think about which syntax I am using and/or the need to restart REPL
manually on each re-evaluation.