requireJS and node-webkit

5 views
Skip to first unread message

daanp

unread,
Dec 12, 2012, 9:15:06 AM12/12/12
to node-...@googlegroups.com
i've seen a few discussions about this but i can't get it to work in my version. I know why we need to add the following javascript before we execute the requireJS:

<script type="text/javascript">
    window.requireNode = window.require;
    window.require = undefined; 
</script>

so that the window require variable is available for requireJS to use and for node you can use the requireNode variable. But when i want to require the nw-gui module it fails ... i think somewhere deep inside it is still using window.require which executes requireJS code now. Any idea how to fix this?

A temporary fix i found was adding this:
<script type="text/javascript">
    window.requireNode = window.require;
    window.gui = window.requireNode('nw.gui');
    window.require = undefined; 
</script>

also defining the gui as a window variable before requireJS is loaded then later in the code i can access the gui module through window.gui.

kind regards,
Daan

Cheng Zhao

unread,
Dec 12, 2012, 7:40:00 PM12/12/12
to node-...@googlegroups.com
I cannot reproduce this problem, requireNode('nw.gui') works fine for
me, can you provide a simple app that can demonstrate it? And can you
try to use

var gui = nwDispatcher.requireNwGui();

and see whether it works?

daanp

unread,
Dec 13, 2012, 7:04:45 AM12/13/12
to node-...@googlegroups.com
I created a simple demo app:

Also the 'var gui = nwDispatcher.requireNwGui();' gives the same error.

kind regards,
Daan

atb...@gmail.com

unread,
Jan 11, 2013, 8:09:17 AM1/11/13
to node-...@googlegroups.com
I had a similar issue, and I simply reset window.require back to window.requireNode, in the beginning of the requirejs callback. 
Reply all
Reply to author
Forward
0 new messages