Categories
JavaScript Answers

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

Spread the love

To run Node.js app with ES6 features enabled, we set the presets option.

For instance, in package.json, we write

{
  "dependencies": {
    "babel-cli": "^6.0.0",
    "babel-preset-es2015": "^6.0.0"
  },
  "scripts": {
    "start": "babel-node --presets es2015 app.js"
  }
}

to add the babel-preset-es2015 package.

And we set the --presets option when we run babel-node to enable the ES6 features.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *