Any ideas on how to use ES6 on WebStorm 10?
Here's what I have done so far:
- Installed Babel.
- Activated Babel with Settings > Tools > File watchers. checked Babel checkbox.
- Edit configurations > Before launch file watchers > + then 'Run File Watchers".
- Set code as ES6
- Changed my run configuration to use the compiled version.
Then created the following trivial piece of code:
require("babel/register");
function* count(n){
console.log(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:
require("babel/register");
(Windows 7, if that is important).
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.
npm install babel-core
--optional runtime
as an argument to the invocation of babelThis is based on what's described in some detail here.