mkdir my_tests
cd my_tests
# you need an npm project to install npm modules locally
npm init -y
npm install --save-dev babel-core babel-cli babel-preset-es2015
# let babel know what version you want to use
echo '{ "presets":["es2015"] } ' > .babelrc
# use the new "import" syntax; here I imported something from redux just to get it to fail
echo 'import { createStore } from "redux";' > t1.js
# this will fail
node t1.js
# this will not fail
./node_modules/.bin/babel-node t1.js
with modules installed globally you don't need a npm project file
mkdir my_other_tests cd my_other_tests npm install -g babel-core babel-cli babel-preset-es2015 # specify the ES version in the command line or create a .babelrc file like above babel-node --presets es2015 t1.js
No comments:
Post a Comment