We use NODE_PATH env variable in our project, it contains several specific "libs" paths where we store all libraries. Inside the code we load them with short line var lib = require('project/lib');
Tern failed to find them because node_resolve plugin looks for files only in standard paths.
var lib = require('project/lib');
This patch adds ability to configure project specific paths for node_resolve plugin. For example .tern-project:
Works fine with tern_for_sublime.
Wouldn't it be an option to simply pass the same environment variable when you run the Tern server? I'm not too keen on adding even more poking into undocumented Node internals here.
There were 3 variants where to place those paths
1st one gives most of conflicts between projects. I have to have several per-project links to open same editor to be sure when I edit one project, libs from another won't be read because of global env var.
2nd one - I actually tried in tern_for_sublime, but stopped because I failed to find out how to make it read per-project settings. Global ones gives same problem as in 1st case. Also downside of this - it will work only in sublime, other editors need coding too.
3rd one - looks like most right place to write this feature, logically. But it's implemented via hack, node doesn't have feature to update lookup paths which exists long time in python or ruby. What to do ...
If it's not acceptable, I'd voted for rewriting whole node_resolver module to spawn separate process with correct environment and do lookup via it, instead of 1st or 2nd variants.
Add lookup_paths option to node_resolve plugin
I have rewritten patch to not use Node internals
Put this in the Modules object, not as a file-global variable. (You could have multiple Tern servers active in a process, with different configurations.)