This article gives you a basic way of setting up your environment if you want to use ES2015 with Node (using v4.3.0 in this tutorial).

Babel libraries

You will first need:

(Babel in itself does not do anything and it is the plugins that will define what it does.)


$ npm install --save-dev babel-cli babel-core babel-preset-es2015

Babel configuration

The standard way of configuring Babel is to use a .babelrc file:

Put a .babelrc configuration file at the root of your project. I don’t like to have too much stuff in there and thankfully you can also put your config in package.json.

Whichever way you choose, inside your configuration put:

"presets": ["es2015"]


Create an index.js file with the following ES2015 code:

var numbers = [1, 4, 9];
var doubles = => num * 2);
console.log(doubles); // [2, 8, 18 ]

Run it with node index.js and check that everything is working.

Create a launcher

When using certain features of ES6, you might encounter an error of type:

SyntaxError: Unexpected token

This means you will need to create a launcher for your app that loads 'babel-core/register' ahead of your code.

Assuming your entry point is index.js, create the following launcher:

// -----------
// launcher.js
// -----------

Start your app with node launcher.js

This will clear the errors.