Nw.js: 'require is not defined'

Created on 11 Apr 2015  路  3Comments  路  Source: nwjs/nw.js

package.json: "main": "htttp://localhost"

The html file is loaded from the server. require('nw.gui') cause an error 'require is not defined'.

However, this error would not appear when this html file is loaded from local directory.

Most helpful comment

I think it's just a case of not having specified a node-remote key in your manifest. For example:

package.json

{
  "name": "your-nwjs-app",
  "main": "http://localhost/",
  "node-remote": "localhost"
}

:warning: DANGER: This grants sources matching the specified node-remote pattern node-level execution privileges. You should be as specific as possible when constructing such patterns.

All 3 comments

Sounds like a case of #199 ?

I think it's just a case of not having specified a node-remote key in your manifest. For example:

package.json

{
  "name": "your-nwjs-app",
  "main": "http://localhost/",
  "node-remote": "localhost"
}

:warning: DANGER: This grants sources matching the specified node-remote pattern node-level execution privileges. You should be as specific as possible when constructing such patterns.

@rdtsc , many thanks for your help! I just try and succeed.

Was this page helpful?
0 / 5 - 0 ratings