I have a Nodeclipse project x, which can be considered as a library, in the form of javascript files. It has a root folder: 'r'. This folder has an 'index.js' file.
A typical module using x starts by: var r = require('r');.
This works well when running Node.js from the cmd line by simply adding the full path to 'r' to NODE_PATH.
Now in another Nodeclipse project y, I add project x as a reference in the 'projects' tab of the 'Include path' properties.
I am expecting that Nodeclipse will do the magic of adding the source folders of x to the include paths of y when running the project. If not what's the use of adding a project?.
However, when hitting: var r = require('r');, Node.js complains it can't find 'r'. Stepping into the source code for 'require', it is obvious that none of the source paths of project 'x' have been added to the include path.
What am I missing?
for what it's worth, I have found a solution. my project structure consists of 3 root folders: - generated - main - test all residing under a folder 'src'.
I have created a script: exploded.js which resides in the src folder. All my test scripts start with: "require('../../exploded') (# of ../ depends on depth) This script overrides Module._resolveLookupPaths and enriches the candidate path list with corresponding paths in the main and generated folders.
Eric
Exploded.js code (didn't find a way to upload it):