Reputation: 1903
I feel like I am missing something simple.
I'm developing a "tray" application in nw.js. To do this I set "main"
to a "main.js"
file in my package.json
. In main.js
I instantiate a Tray
object and call nw.Window.open('file://' + path.join(__dirname, 'index.html'))
on the click event of the tray object.
It's all working fine, except I am not able to use require
in any scripts inside index.html
. I get an error saying:
Uncaught ReferenceError: require is not defined
Note that if I set "main"
to "index.html"
in the package.json
, everything works fine. The problem only shows up when open index.html
using nw.Window.open('file://' + path.join(__dirname, 'index.html'))
.
I have a feeling it has something to do with the node-remote
option in package.json
, but I can't quite figure it out.
Upvotes: 0
Views: 1376
Reputation: 1903
Replacing
nw.Window.open('file://' + path.join(__dirname, 'index.html'))
with
nw.Window.open('index.html')
did the trick.
Upvotes: 1