All notes

babel-cli cli.

Quick start

# Always run babel-cli in a local environment.
npm init
npm install --save-dev babel-cli

# Remove babel-cli if it is installed globally.
npm uninstall --global babel-cli

# Error: Unexpected token import
# Since Babel is focusing on being a platform for JavaScript tooling and not an ES2015 transpiler, we’ve decided to make all of the plugins opt-in. This means when you install Babel it will no longer transpile your ES2015 code by default.
# To make it transpile ES6:
npm install -S babel-preset-es2015
# or with yarn
yarn add babel-preset-es2015 --dev
# And enabled the preset in .babelrc
# {
#   "presets": ["es2015"]
# }

# Then you should use babel-node to run es6 scripts:
# Babel comes with a CLI babel-node which works exactly the same as Node.js's CLI, only it will compile ES6 code before running it.
babel-node myscript.js

Command line

babel script.js -o script-compiled.js --presets=es2015,react