exports in node-main do not return to process.mainModule.exports
See original GitHub issueIn 0.12.x if one declared exports
in the node-main file, the same would be visible in process.mainModule.exports
In node-main
exports.pi = 3.14;
In the app
console.log(process.mainModule.exports); //output {pi:3.14}
This does not happen in nwjs 0.13 (tested in beta 5 and beta 6 - winx64 SDK version):
console.log(process.mainModule.exports); //output {}
Has there been any change in the api or is this a bug?
Issue Analytics
- State:
- Created 8 years ago
- Comments:14 (4 by maintainers)
Top Results From Across the Web
process.mainModule is deprecated in nodejs - Stack Overflow
module.exports = path.dirname(process.mainModule.
Read more >CommonJS modules | Node.js v19.3.0 Documentation
Assigning to exports will not modify module, must use module.exports ... point is not a CommonJS module, require.main is undefined , and the...
Read more >Node.js process.mainModule Property - GeeksforGeeks
Return Value: This property returns an object that contains the reference of main module. Below examples illustrate the use of process.
Read more >modules
The module.exports property can be assigned a new value (such as a function or object). Below, bar.js makes use of the square module,...
Read more >Modules Node.js v0.10.29 Manual & Documentation - Index of
assigning to exports will not modify module, must use module.exports module.exports = function(width) { return { area: function() { return width * width;...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@rogerwang Again, I appreciate the work that is going in and grateful that this project exists (which was a bit of a revolution at its time). But the fact this was not addressed at the time 0.13.0 or the fact that nwjs team is unaware that till 0.24 that the problem was resolved is something that needs to be tackled head on (if @Christywl makes progress in this effort more power to him). My continued frustration is that nwjs is a pretty mature project, funded by an industry leader like Intel and you guys MUST act like industry leaders not benchmarking yourself against other open-source projects. As an innovator you shd not argue like below:
Again I wish you well and I hope you make great strides…
I believe “process” has been moved to the “nw” object, try using:
nw.process.mainModule.exports.foo();
I’m getting some success with using “nw”, but after a while, I can use plain-old “processes”. Results are a moving target.