I wouldn't recommend to add paths to NODE_PATH
.
In your package.json you can link modules directly to repositories url:
"dependencies": {
"myModels": "git+https://user:pass@github.com/myAccount/my-models.git#v0.6"
"myTemplates": "git+ssh://github.com/myAccount/my-templates.git#v0.2"
}
As you can see you can reference tags, branches or whatever you want. You can use different versions for each application. Just update your tag, branch and npm install
.
IMHO, i wouldn't use git submodules you can mess things up pretty bad. You can (accidentally) push the outer module with a reference to the submodule before actually pushing the submodule and nobody else would be able to work since they wont have those commits that are only in your machine). Also, submodules are always checked out in detached HEAD mode and there are a few more issue regarding branching and merging.
If my argument is not good enough to make you not use submodules and you go ahead, instead of updating NODE_PATH
you can just add a proxy file to your node_modules to avoid relative paths:
In node_modules/models.js:
module.exports = require('../lib/models');
This might not be the best thing to do but you'll avoid relative paths for that module all across the application.
If you have node_modules under .gitignore you'll have to omit this one file:
node_modules/*
!node_modules/models.js
And you might want to add it to bundledDendencies
in package.json. Yeah, it's a bit messy but you'll avoid relative paths and be able to move folders around with messing things up (too much).
Long story short: Adding your business dependencies to package.json might be what you are looking for.