Is there any way to migrate ES5 code to ES6? I searched for some examples regarding the fact of using latest Node.js and it always gave me an error even with harmony flag. Error included message that there are invalid syntax even for "let" keyword. I wrote to console v8 options and seems everything is turned on..
I'm trying to migrate my framework http://twee.io
ES5 code will work along side of ES6 code already. For nodejs just install babel core:
npm install babel-core --save
and you'll also need
npm install babel-preset-es2015 --save
create a .babelrc file with the following:
{
"presets": [ "es2015"],
"ignore": "node_modules"
}
run your node app via, (assumes your file is app.js)
babel-node app
alternatively you can add require('babel-core/register');
at the top of your node project and any code below will be transpiled with babel...
a recommended way is to create something like main.js with the following contents:
require('babel-core/register');
require('./app.js');
then just run node main.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With