As asked for at https://github.com/joyent/node/issues/7126, when defining 
tests and examples on a Node.js package, you can't be able to require() the 
package itself, needing to do it directly over the Javascript files. It's 
said, instead of

var myModule = require('myModule');

you needs to do

var myModule = require('../lib/index.js');

This has the problem that both examples and tests doesn't follow the same 
behaviour than third party code that makes use of that module, leading to 
problems and also making it inconsistent since you can require() other 
modules that are on the node_modules folder. To fix this, I propose that 
require() resolve algorythm takes in account also the current package when 
searching for modules. This should be easy, since when scaling over the 
filesystem hierarchy this is located in the same point where a package.json 
file or a node_modules folder is found, so it would only need to check for 
the current package before going into the node_modules folder. Another 
alternative would be to add dinamically the current package root folder to 
the NODE_PATH environment variable.

Following advice from @indutny on the GitHub issue pointed before, I've 
open this topic for discussion about if this should be implemented.

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to