When I run node
from the command line with no arguments, I enter an interactive shell. If I execute some commands, exit node, and restart node, the up arrow doesn't do anything (I'd like it scroll through my previous commands).
Is there a way I can invoke node interactively such that it will remember my old commands?
bash_history exists. If it does not, there's nowhere for bash to save command history. this just creates the empty . bash_history file in your home directory, which will fill up with your commands, and should persist between sessions.
Installing forever Forever can be used in two ways: with the forever CLI tool and with forever-monitor. The forever-monitor tool can be used to run an application with forever using code.
The Node. js Read-Eval-Print-Loop (REPL) is an interactive shell that processes Node. js expressions. The shell reads JavaScript code the user enters, evaluates the result of interpreting the line of code, prints the result to the user, and loops until the user signals to quit. The REPL is bundled with every Node.
You could use rlwrap to store node.js REPL commands in a history file.
First, install rlwrap (done easily with a package manager like apt-get or brew etc).
Then add an alias for node:
alias node='env NODE_NO_READLINE=1 rlwrap node'
I'm on OSX so I add that alias to my ~/.bash_profile
file, and would reload my bash_profile file via source ~/.bash_profile
.. and I'm good to go!
Hope this helps!
I found a nice little project, which solves the problem:
https://www.npmjs.org/package/repl.history
install using npm (npm install -g repl.history
) and run repl.history
on the command line.
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