Tuesday, September 5, 2017

How to use ES6 in Node using Babel

Install Babel CLI
npm install --save-dev babel-cli

Add Presets
$ npm install --save-dev babel-preset-es2015 babel-preset-stage-2

Add .babelrc
    "presets": ["es2015", "stage-2"]

Add ES6 code to index.js

Add start script in pakage.json
"start": "babel-node index.js"

Start server
npm start

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

Receive all updates via Facebook. Just Click the Like Button Below

You can also receive Free Email Updates: