Closed vitkarpov closed 10 years ago
For CommonJS it's using module.exports
, not window: https://github.com/sindresorhus/screenfull.js/blob/46c1db251b1fece41a7097eece969a74100788b1/src/screenfull.js#L145-L146
I think we didn't understand each other. Sorry about that, I'll try to explain one more time.
There is some module, let a.js
. Inside the module we have a such line of code: var screenfull = require('screenfull');
.
When I use a
module in a browser — everything is ok: screenfull works. Now I try to use it in nodejs (certainly, I don't need to use screenfull, but it should be parsed without errors such as it's required inside a
).
When I try to require the a module I see such errors:
document is not defined
or
window is not defined
It occurs 'cause of inside screenfull
it should be global.document
, not just document
.
Is it clear now?
It's convenient to use
global
instead ofwindow
in commonjs way. There's no sense to use module in nodejs environment but it should can be interpreted anyway.