如何使用ECMAScript 6 node.js v4.2.1

3 javascript unix node.js ecmascript-6

当我尝试使用let它时返回:

(function (exports, require, module, __filename, __dirname) { let i = 0;
                                                              ^^^

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:414:25)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Function.Module.runMain (module.js:467:10)
    at startup (node.js:134:18)
    at node.js:961:3
Run Code Online (Sandbox Code Playgroud)

我听说v4有ECMAScript 6支持而不需要babel.

slo*_*mek 5

您需要处于严格模式(请参阅错误消息)才能使用ES6功能:

"use strict";
let yourcode = "here";
Run Code Online (Sandbox Code Playgroud)

编辑:谢谢@ user5448026,我完全搞砸了.