question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

exports in node-main do not return to process.mainModule.exports

See original GitHub issue

In 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:closed
  • Created 8 years ago
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
CxRescommented, Oct 12, 2017

@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:

dilbert_mediocrity-23259stripzoom

Again I wish you well and I hope you make great strides…

1reaction
bobtherobotcommented, Mar 17, 2016

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found