简体   繁体   English

修改node.js REPL为“默认值”吗?

[英]Modify node.js REPL “defaults”?

I'm a node.js beginner. 我是一个node.js初学者。 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. 我想修改节点的默认REPL的行为,如描述下这个环节 ,但我希望运行启动脚本,因为这样做将启动REPL不导入现有的历史文件。 (I know this because I tried the code from the first answer: the modified REPL started, but prior history wasn't available.) (我知道这一点是因为我尝试了第一个答案中的代码:修改过的REPL开始了,但是以前的历史记录不可用。)

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. 注意:我也尝试过将rlwrap与-H path / to / .node_repl.history一起使用,如该线程中所建议,与第一个链接中的脚本结合使用,仍然没有运气。 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. 我的bashrc可以达到我想要的效果,而不会破坏现有的历史记录。 I'm not sure how well this will work for changing multiple REPL defaults, so I'm not marking this as an answer yet. 我不确定这对于更改多个REPL默认值的效果如何,因此我还没有将其标记为答案。

UPDATE Unfortunately, the latest node.js update broke this. 更新不幸的是,最新的node.js更新打破了这一点。 I believe this is the pull request responsible. 我相信是负责的请求请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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