Option 1 - Change NODE_PATH (not recommended):
Modify NODE_PATH to include the path to the module in the shell before running node.js.
exports NODE_PATH=./path/to/module:$NODE_PATH
This is not a great option, because it requires a step before starting and - since NODE_PATH contains many paths - it does not always NODE_PATH where the module is loading, and there is a possibility of name conflicts.
Option 2 - Move the module to an external repo
Suppose you move components to a separate rootcomponents repo resource, available on your GitHub profile.
Then you can install it directly through:
npm install
Then you should be able to map the project source to the alias System.js.
var systemJsConfig = { baseURL: "./", defaultJSExtensions: true, map: { 'root-components': 'github:arackaf/rootcomponents' } };
From there, it should work as you expected:
require('root-components/foo');
Option 3 - Download the module through the relative path:
The config.map parameter config.map intended only for matching external dependencies with aliases.
One simple alternative is to provide a relative path. Sibling paths are based on the URL.
For example, if you are trying to download:
src/rootComponents/foo.js
Demand:
require('./src/rootComponents/foo')
Note. All of this assumes that require() statements follow System.js patterns / rules.
Another possible option is to provide the System.paths[] parameter, which creates an alias for the local path. I can’t check how this works (i.e. I have never tried), but can be found here here