Dirk Dirk - 1 year ago 128
Javascript Question

Getting ES6 to work in WebStorm

Any ideas on how to use ES6 on WebStorm 10?

Here's what I have done so far:

  1. Installed Babel.

  2. Activated Babel with Settings > Tools > File watchers. checked Babel checkbox.

  3. Edit configurations > Before launch file watchers > + then 'Run File Watchers".

  4. Set code as ES6

  5. Changed my run configuration to use the compiled version.

Then created the following trivial piece of code:

function* count(n){

This code shows up with no syntax errors, as it should. (A convenient way to make sure ES6 is turned on).

Run it (run the compiled version, actually), and get this ....

var marked0$0 = [count].map(regeneratorRuntime.mark);
ReferenceError: regeneratorRuntime is not defined

Why? How do I get it to precompile with Babel and then run? Isn't the regenerator supposed to be taken care of with this line:


(Windows 7, if that is important).

Answer Source

I think there are two things you probably need to do to make it work based on the nature of the error you're describing.

  1. npm install babel-core
  2. add --optional runtime as an argument to the invocation of babel

This is based on what's described in some detail here.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download