How to run Node.js app with ES6 features enabled?

后端 未结 8 1925
[愿得一人]
[愿得一人] 2020-12-02 06:31

I use the require hook of BabelJS (formerly named 6to5) to run node apps with es6features:

// run.js
require(\"babel/register\");
require(\"./app.js6\");
         


        
8条回答
  •  北海茫月
    2020-12-02 06:54

    As of babel 6, you now must install babel-register and use the following

    require("babel-register");
    

    Be sure to also install the babel es2015 preset.

提交回复
热议问题