Node.js REPL continuation lines

安稳与你 提交于 2019-12-24 16:59:58

问题


When working with the node.js repl, is there a way to quit a continuation line that node is being over zealous with?

For example:

$ node
> {- -}
... 

And pretty much everything you can type then gives you another continuation line. Ctrl+D quits the whole repl.

Obviously I don't want to go around typing {- -} all the time, but I do find I often type something erroneous when I'm using the repl to experiment. Then I have to quit the repl, and loose all the bits in memory.


回答1:


You can also type:

.break

Type

.help

for more REPL options... the .clear command may also be useful because it breaks and clears the local context, in case you want to save yourself the trouble of exiting and restarting the repl.




回答2:


Sorry - I really should experiment more and Google less.

The answer (at least on Ubuntu) is Ctrl+C.

Ctrl+C first quits any continuation. Then if you hit it again prints

(^C again to quit)

Then quits, as it says.

In the interest of making this question more useful, just tested this and the same thing works in Python's repl, Guile. But doesn't work in Rhino, where it quits the repl entirely.



来源:https://stackoverflow.com/questions/6734712/node-js-repl-continuation-lines

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!