In this series of articles we are going to understand all new features of
ES6 with the help of NodeJS.

Let’s start with setup.

Before moving ahead make sure that npm and NodeJS are properly installed on your machine.

For Ubuntu users only, follow these three commands to set it up.

 $ sudo apt-get update
 $ sudo apt-get install nodejs
 $ sudo apt-get install npm

Now, create one directory, for example, hello_world and move to that directory.

$ mkdir hello_world && cd hello_world

Initialize your sample node application using npm

$ npm init

After initializing the app, you can see a package.json file in that directory.

Edit that file with some dependencies and scripts. Here, we are adding two dependencies:

  1. babel-cli : It is used for babel command line tool.
  2. babel-preset-es2015 : It is used as babel preset for all es2015 plugins. This will help us to use ES6 features and to transpile it into ES5.

Add below in your package.json exisiting file

{
 "dependencies": {
 "babel-cli": "6.0.0",
 "babel-preset-es2015": "6.0.0"
 },
 "scripts": {
 "start": "babel-node - presets es2015 app.js"
 }
}

Final version of package.json should look like

{
 "name": "Demo",
 "version": "1.0.0",
 "description": "Initial Setup",
 "main": "index.js",
 "dependencies": {
 "babel-cli": "6.0.0",
 "babel-preset-es2015": "6.0.0"
 },
 "scripts": {
 "start": "babel-node - presets es2015 app.js",
 "test": "echo \" Error: no test specified\" && exit 1"
 },
 "author": "Nishant",
 "license": "ISC"
}

Now, from your terminal run command

$ npm install

Let’s add new file app.js in root path of directory to test that ES6 works fine or not.

// Don't worry about the code, we will learn it soon.
let world = 'World';
console.log('Hello ${world}');

Now, test it by running,

$ npm start

It should print Hello World in your terminal.

That’s it! Your setup for ES6 and Node JS is ready for use. Now we are going to learn some new exciting features of ES6 in my next article. So please keep in touch and keep reading.


At BoTree Technologies, we build web and mobile applications to add value to our client’s business. We align ourselves to ensure that our client benefits the most out of our engagement.

We work in Ruby on RailsPython, Java, React, Android, iOS and RPA as well.

Drop us a line to discuss how can we help take your business to the next level.