require not working in HTML files after adding node-main file

12 views
Skip to first unread message

michel.beau...@lri.fr

unread,
Jan 21, 2013, 11:39:21 AM1/21/13
to node-...@googlegroups.com
I don't know if this is a bug or a feature:

- I had an app without a node-main file. The html files used require without problem, e.g. require('jade') or require('nano').
- I added a node-main file to this app, and now it says "Cannot find module 'jade'" or "'nano'".

I found a way around by requiring the module in the node-main file and passing it to the HTML files through global:
    node-main:
        global.jade = require('jade');
    index.html:
        var jade = global.jade; // require('jade') does not work when there is a node-main is package.json

Why is it that adding a node-main file changes the way require works in the HTML file?
I would also rather require the module where I need them, rather than having to load them all in the node-main file.

Thanks,
michel

PS: issue is the same with node 0.3.7 and 0.4.0

Roger WANG

unread,
Jan 21, 2013, 8:23:36 PM1/21/13
to michel.beau...@lri.fr, node-...@googlegroups.com
<michel.beau...@lri.fr> writes:

> I don't know if this is a bug or a feature:
>
> - I had an app without a node-main file. The html files used require
> without problem, e.g. require('jade') or require('nano').
> - I added a node-main file to this app, and now it says "Cannot find module
> 'jade'" or "'nano'".

It should be a bug. I cannot reproduce it here. Could you please open an
issue and post the source code there?

https://github.com/rogerwang/node-webkit/issues/new

Thanks in advance.

--
Roger WANG Intel Open Source Technology Center

Reply all
Reply to author
Forward
0 new messages