How do I get Babel 6 to compile to ES5 javascript?

后端 未结 3 1090
-上瘾入骨i
-上瘾入骨i 2020-12-08 02:08

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(         


        
3条回答
  •  没有蜡笔的小新
    2020-12-08 02:09

    The exact answer using babel with nodejs (and using CLI):

    Install babel and preset

    npm install babel-cli babel-preset-es2015
    

    Execute with npx

    npx babel  ./src/myclass.js --out-file ./out/app.js --presets babel-preset-es2015
    

    Note

    When babel-cli is globally installed could be not working. So this is my definitive solution

提交回复
热议问题