how to execute es6 scripts from CLI
1) To enable the support of ES6, use the --harmony
flag:
node --harmony myscript.js
This will enable the available ES6 syntax in node. But notice it's currently a limited subset of the ES6 standard (see the compatibility table).
2) To have a complete compatibility, you have to use babel node.
Install @babel/node
to get a babel-node
executable which works exactly the same as Node.js's CLI, only it will compile ES6 code before running it.
babel-node myscript.js