为什么我不能在节点REPL中打开严格检查?

时间:2014-01-14 02:43:00

标签: javascript node.js

我想全局启用严格检查。

> use strict;
...  // waits for more input


> "use strict";
'use strict'  // but does not turn on sanity checks

我错过了什么吗?

2 个答案:

答案 0 :(得分:0)

如果您正在运行Node> = 0.10.7,请运行node --use_strict

答案 1 :(得分:0)

你不能因为每一行都是它自己的功能。

你可以在这样的每一行前加上'use strict':

> 'use strict'; with({}){} // throws

或运行节点--use_strict