我想评价
var foo = "foo";
console.log(foo);
作为一个 block ,而不是逐行评估
var foo = "foo";
undefined
console.log(foo);
foo
undefined
有没有一种简单的方法可以将提示移到下一行?
最佳答案
Node v6.4 具有 editor
模式。在 repl 提示符下输入 .editor
可以输入多行。
例子
$ node
> .editor
// Entering editor mode (^D to finish, ^C to cancel)
const fn = there => `why hello ${there}`;
fn('multiline');
// hit ^D
'why hello multiline'
> // 'block' gets evaluated and back in single line mode.
这里是所有特殊 repl 命令的文档 https://nodejs.org/api/repl.html#repl_commands_and_special_keys
关于node.js - 如何在 Node REPL 中编写多行代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29203892/