Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/406.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 为什么我不能通过“启动和谐模式”;节点——harmony test.js“;从命令行?_Javascript_Node.js_Ecmascript 6_Ecmascript Harmony - Fatal编程技术网

Javascript 为什么我不能通过“启动和谐模式”;节点——harmony test.js“;从命令行?

Javascript 为什么我不能通过“启动和谐模式”;节点——harmony test.js“;从命令行?,javascript,node.js,ecmascript-6,ecmascript-harmony,Javascript,Node.js,Ecmascript 6,Ecmascript Harmony,问题是: longhao33@hePC:~$ node --harmony test.js /home/longhao33/test.js:1 (function (exports, require, module, __filename, __dirname) { let str = 'es666666666666'; ^^^ SyntaxError: Block-s

问题是:

longhao33@hePC:~$ node --harmony test.js 
/home/longhao33/test.js:1
(function (exports, require, module, __filename, __dirname) { let str = 'es666666666666';
                                                              ^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:413:25)
    at Object.Module._extensions..js (module.js:452:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:475:10)
    at startup (node.js:117:18)
    at node.js:951:3
但是当:时支持“let”(太奇怪了!)

longhao33@hePC:~$ node --harmony
> let str = 'es66666666666'
undefined
> str
'es66666666666'
  • 系统:ubuntu 14.04LTS 64位
  • 节点:V4.1.1(由nvm安装,安装在$HOME)
  • test.js的内容:

    设str='es6666'; console.log(str)


  • 提前感谢。

    您缺少
    “严格使用”位于
    test.js的顶部(如错误消息所示)


    它在REPL中起作用,因为。

    您缺少
    “使用严格的”位于
    test.js的顶部(如错误消息所示)

    它在REPL中工作是因为