简体   繁体   中英

Modify node.js REPL “defaults”?

I'm a node.js beginner. I want to modify the behavior of node's default REPL, as decribed in this link , but I don't want to run a startup script because doing so starts the REPL without importing the existing history file. (I know this because I tried the code from the first answer: the modified REPL started, but prior history wasn't available.)

Is this possible? Or would it be easier to figure out how to add/import the existing history file and add said code to a startup script?

NOTE: I also tried using rlwrap with -H path/to/.node_repl.history, as suggested in this thread , combined with the script from the first link, and still no luck. I get the modified behavior, but no history.

Don;t know if this is the 'right' way to do this, but it works for me:

Adding

alias node='node -e repl.repl.ignoreUndefined=true -i'

to my bashrc achieves the effect I'm looking for without clobbering existing history. I'm not sure how well this will work for changing multiple REPL defaults, so I'm not marking this as an answer yet.

UPDATE Unfortunately, the latest node.js update broke this. I believe this is the pull request responsible.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM