souparno majumder souparno majumder - 1 year ago 214
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
I tried to install the

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 Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download