Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Weird problems with module.exports
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Andreas Richter  
View profile  
 More options Sep 6 2012, 7:01 am
From: Andreas Richter <richt...@gmail.com>
Date: Thu, 6 Sep 2012 04:01:09 -0700 (PDT)
Local: Thurs, Sep 6 2012 7:01 am
Subject: Weird problems with module.exports

One of my modules was using:

module.exports = { loadModules: loadModules, initModules: initModules,
eventRouteModules: eventRouteModules, notifyDependenciesOfInit:
notifyDependenciesOfInit,
notifyDependenciesOfRoute: notifyDependenciesOfRoute, registerDependencies:
registerDependencies, loadAbout: loadAbout };

instead of:

module.exports.loadModules = loadModules;
module.exports.initModules = initModules;
module.exports.eventRouteModules = eventRouteModules;
module.exports.notifyDependenciesOfInit = notifyDependenciesOfInit;
module.exports.notifyDependenciesOfRoute = notifyDependenciesOfRoute;
module.exports.registerDependencies = registerDependencies;
module.exports.loadAbout = loadAbout;

Seems harmless and worked pretty much 99% of the time. However when running
mocha on TravisCI it would fail saying it couldn't find loadAbout.
I tried many different things and could not narrow it down to anything else
but this change. The issue occurs both on node 0.6 and 0.8 based versions.
Locally I tested the same variations on Mac OS and ubuntu and they did not
show the problem.

Does anyone have any ideas why this would cause problems on some platforms?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sitnin  
View profile  
 More options Sep 7 2012, 2:57 am
From: Sitnin <sit...@ya.ru>
Date: Thu, 6 Sep 2012 23:57:44 -0700 (PDT)
Local: Fri, Sep 7 2012 2:57 am
Subject: Re: Weird problems with module.exports

I have two ideas:

1) try to use exports, not module.exports. Here is the
difference: http://www.hacksparrow.com/node-js-exports-vs-module-exports.html

2) I encountered similar problem when testing my code with invalid
environment. I had a Makefile which was running mocha tests but doesn't set
proper working directory and environment variables for the Node so it can't
load my modules. Maybe you could investigate in that direction.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mariusz Nowak  
View profile  
 More options Sep 7 2012, 4:14 am
From: Mariusz Nowak <mari...@medikoo.com>
Date: Fri, 7 Sep 2012 01:14:27 -0700 (PDT)
Local: Fri, Sep 7 2012 4:14 am
Subject: Re: Weird problems with module.exports

Within Node.js such issue may occur *only* when your dealing with cyclic
dependencies. If it's the case just move require's to modules in question
to end of the file (after assignment to module.exports), it will fix that.

You say it's Travis error, so maybe it's the case of circular dependencies
between packages? See this issue: https://github.com/isaacs/npm/issues/2063
there's also solution for that.

If it's none of the above, then either you misinterpreted something, or
your modules are not loaded natively by Node but not in a compliant way by
some other stuff in the middle, that could be the only explanation.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »