Search code examples
node.jsread-eval-print-loop

save nodejs history from interactive command-line session


After using node in interactive/command line mode to explore, how can I copy my command history to a text file for my own future records?

The up arrow key recalls previous node statements, and furthermore already persists across logins, so the history is already being saved somewhere in node.js. But where is it saved? How can I copy it?

But I could find nothing in node --help


Solution

  • The read-evaluate-print-loop or REPL has a documented list of special nodejs REPL commands, including a save command:

     .save /path/to/save/my/history 
    

    Also, look in ~/.node_repl_history