I am using NodeJS version 4.2.1
I want to know the command for clearing the NodeJS REPL console history completely so it doesn't show previously executed commands when Up or Down arrow keys are pressed.
Any suggestions ?
You can add functionality to node's REPL so that you can clear it in the same way your can clear Chrome's JavasSript Developer Console. If you copy and paste this function into the nodejs console, you can then call clear(); each time you want to clear the screen.
To exit the REPL, you can type . exit , or press CTRL+D once, or press CTRL+C twice, which will return you to the shell prompt.
Per the nodejs documentation which can be found at the following link:
nodejs repl
Environment Variable Options
The built-in repl (invoked by running node or node -i) may be controlled via the following environment variables:
NODE_REPL_HISTORY - When a valid path is given, persistent REPL history will be saved to the specified file rather than .node_repl_history in the user's home directory. Setting this value to "" will disable persistent REPL history. NODE_REPL_HISTORY_SIZE - defaults to 1000. Controls how many lines of history will be persisted if history is available. Must be a positive number. NODE_REPL_MODE - may be any of sloppy, strict, or magic. Defaults to magic, which will automatically run "strict mode only" statements in strict mode.
Persistent History
By default, the REPL will persist history between node REPL sessions by saving to a .node_repl_history file in the user's home directory. This can be disabled by setting the environment variable NODE_REPL_HISTORY="".
The answer is actually simple :)
On Windows (my version is 10):
cd %userprofile%
echo. > .node_repl_history
and it will have same effect.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With