These instructions will allow you to write and run one-off node.js scripts using modern ECMAScript syntax, including async/await.
- Install Babel globally
npm install -g babel-cli
- Add a
.babelrc
file to the folder holding your code containing the following:
{ "presets": [ "es2015", "stage-3" ] }
- Run your ES6/ES7 script with
babel-node {script}.js
Alternatively, you can skip the .babelrc
file creation and just run babel-node --presets es2015,stage-3 {script}.js