Switching from Electron to NWjs: regeneratorRuntime?

225 views
Skip to first unread message

Steve Beisner

unread,
Sep 25, 2016, 2:47:27 PM9/25/16
to nw.js
I'm try to switch a large-ish application from Electron to NW.
I'm using .es6 modules and other features via Babel and
browserify.   

I start each es6 module with 'import "babel-polyfil";'.
 
While the Electron version works fine, the NW.js
version produces
    "regeneratorRuntime is not defined"
at startup.

Anyone have a clue as to why NW.js is different
from Electron in this respect?

Thanks,
SteveB

Steve Beisner

unread,
Sep 25, 2016, 4:27:51 PM9/25/16
to nw.js
OK... I figured it out. It was my confusion about browser context vs. nodejs context.
I added this to my start-up html file:
<script type="text/javascript">
    window.require("babel-polyfill"); 
    // Move a couple of things into the browser context's window object
    // from the node context's global object. 
    window.__dirname = global.__dirname;
    window.regeneratorRuntime = global.regeneratorRuntime;
</script>
That fixed it.

If anyone has another solution, I'd be delighted to hear about it!
~SteveB

b.de...@gmail.com

unread,
Dec 8, 2017, 3:23:30 PM12/8/17
to nw.js
Thanks for your solution.
I had the same issue with converting an Chrome App to NW.js.
This line solved the issue for me.

window.regeneratorRuntime = global.regeneratorRuntime;

Gr. Bas.

Op zondag 25 september 2016 20:47:27 UTC+2 schreef Steve Beisner:
Reply all
Reply to author
Forward
0 new messages