JavaScript ES6 Environment Setup

To start experimenting with JavaScript, you'll want to download the latest stable version of Node. Node is a platform that runs on Google's V8 JavaScript Engine. It allows you to build fast and scalable applications using pure JavaScript.

Downloading Node

Visit Node's download page to download the latest stable version of Node. It should prompt you for installation instructions. Follow the prompts and once everything completes you can check to see if it was installed correctly via:

$ node -v

If everything was installed correctly, you should see something similar in the terminal window:

$ node -v

By running the node -v command, we check the version of the Node installation. Please note that v6+ is required to support (most) ES6 features natively in Node. We strongly recommend installing Node v6+ for this tutorial.

Launch the Node console

To follow the examples in this tutorial, you can launch the Node console to write ES6 JavaScript in an interactive environment. Open your terminal, type node, and hit ENTER. You should see something like this:
$ node

This is Node's interactive console environment. It allows you to execute JavaScript on the fly and is perfect for learning the basics.

Write your first line of code

While still in the Node console, enter 2 + 2 and hit ENTER. You should see the result printed below:

> 2 + 2

You've written your first line of JavaScript. While this is standard arithmetic, it demonstrates how you can use the console to execute JavaScript on the fly. Notice how the result 4 is returned.

Exiting the console

To exit the console, simply type .exit.


It's important to understand that JavaScript typically runs in your browser. If you wanted to, you could place JavaScript code between a <script> tag and launch it in the browser of your choice to execute.

The main problem with this is ES6 isn't fully supported by all browsers yet. While transpilers like Babel exist to convert ES6 into ES5, running JavaScript from the console is a better way to get started. We'll eventually look at Babel and how to convert ES6 code for production apps, but lets continue using the Node console for now.

Next, we'll look at basic ES6 syntax.

Join the conversation...

Posted by stackchief
September 6, 2017

the console is a great way to get started learning ES6. it's important to get the basics down before exploring tools like Babel and Webpack. These tools make it easy to convert your ES6 JavaScript to ES5, but will get in the way when you are just exploring the basics.