node.js REPL“未定义" [英] node.js REPL "undefined"

查看:92
本文介绍了node.js REPL“未定义"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从节点0.4.11升级到0.6.15,并注意到REPL(无参数的运行节点)在大多数命令或回车符返回后始终转储未定义" ...

Upgraded from node 0.4.11 to 0.6.15, and noticed the REPL (running node with no arguments) keeps dumping "undefined" after most commands or carriages returns...

这分散了我的注意力,并驱使我前进,如何禁用此功能?

It's distracting and driving me batty, how do you disable this?

> 
undefined
> 
undefined
> 
undefined
> 
undefined
> var x = 2
undefined
> x
2
>

推荐答案

请参阅Node.js REPL 文档页面.

See the Node.js REPL documentation page.

具体是这样:

如果ignoreUndefined设置为true,则repl如果为undefined,则不会输出命令的返回值.默认为false.

If ignoreUndefined is set to true, then the repl will not output return value of command if it's undefined. Defaults to false.

示例代码:

var net = require("net"),
    repl = require("repl");

repl.start(null, null, null, null, true);

示例输出:

> var x
> var blah

此外,您可以将node别名为

node -e "require('repl').start(null, null, null, null, true)"

这篇关于node.js REPL“未定义"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆