I've installed the latest version of babel. Currently 6.4.0. I create a file called myclass.js that has the following code.
class MyClass {
constructor(name) {
console.log("I am a MyClass object .. ", name);
}
}
var myclass = new MyClass('1234');
after creating my class I do the following in the command line.
$> babel ./src/myclass.js --out-file ./out/app.js
I would expect my app.js file to have es5 compiled javascript but it has the same exact code in it that the myclass.js file has. What am I missing that may be causing this?
The exact answer using babel with nodejs (and using CLI):
npm install babel-cli babel-preset-es2015
npx babel ./src/myclass.js --out-file ./out/app.js --presets babel-preset-es2015
When babel-cli is globally installed could be not working. So this is my definitive solution