ES2016 preset

Only compiles what's in ES2016 to ES2015

If you want to stay up to date, use the env preset

This preset includes the following plugins:

Basic Setup (with the CLI)

For more info, check out the setup page on the cli and the usage docs.

Basic Setup (with the CLI)

For more info, check out the setup page on the cli and the usage docs.

Install the CLI and this preset

npm install --save-dev babel-cli babel-preset-es2016

Make a .babelrc config file with the preset

echo '{ "presets": ["es2016"] }' > .babelrc

Create a file to run on

echo 'console.log(2 ** 3)' > index.js

Run it

./node_modules/.bin/babel-node index.js

安装

npm install --save-dev babel-preset-es2016

使用

通过 .babelrc (推荐)

.babelrc

{
  "presets": ["es2016"]
}

通过 CLI

babel script.js --presets es2016

通过 Node API

require("babel-core").transform("code", {
  presets: ["es2016"]
});