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.