souparno majumder souparno majumder - 10 days ago 6
Javascript Question

how to convert babel to javascript in the terminal

I was trying to convert the es6 to plain javascript and i came across this online feature babeljs.io
I tried to install the

babel-core
babel-repl
or even tried
babel myfile.js > output.js
but the
=>
of the es6 features are not getting converted into plain javscript like the website link mentioned.
How should i do it correctly?

Answer

What you need is babel-preset-es2015.

Arrow functions are not transpiled by default. This is because "ES6" is plain javascript. It is a part of the official standard. The preset babel-preset-es2015 tells babel you want to use ES5 standards.

$ npm install babel-preset-es2015
$ babel --presets es2015 myfile.js > output.js