Node.js REPL history

Node.js has included a persistent history with it’s REPL (real-eval-print loop)
for quite some time now. It’s a fantastic quality of life feature, and it even
supports reverse-i-search.

The other day, I got to wondering, where the heck does this history even live?

Turns out, it’s just living in a text file in your home directory, similar to
how bash and zsh handles it.

The file in question is, ~/.node_repl_history.

It contains a history, sans any sort of time of execution, of the commands
you’ve entered into the Node.js REPL. The most recent entries are at the top of
the file.

Since it’s just a simple text file, if you ever did want to clear the file out,
you could do so by running:

echo > ~/.node_repl_history
Josh Sherman - The Man, The Myth, The Avatar

About Josh

Husband. Father. Pug dad. Musician. Founder of Holiday API, Head of Engineering and Emoji Specialist at Mailshake, and author of the best damn Lorem Ipsum Library for PHP.


If you found this article helpful, please consider buying me a coffee.