Option 1 - Modify NODE_PATH
(not recommended):
Modify NODE_PATH
to include the module path in the shell prior to launching node.js.
exports NODE_PATH=./path/to/module:$NODE_PATH
This is not a great option because it requires a pre-launch step and -- since the NODE_PATH
contains many paths -- it's not always clear where the module is being loaded from and there's the possibility of name collisions.
Option 2 - Move the module into an external repo
Lets say you move the components into a separate 'rootcomponents' repo available on your GitHub profile.
Then you can install it directly via:
npm install --save github:arackaf/rootcomponents
Then you should be able to map the project source to a System.js alias.
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 - Load the module via relative path:
The config.map
option is only for mapping external dependencies to aliases.
One simple alternative is to provide a relative path. Relatives paths are based on the baseURL.
For instance, If you're attempting to load:
src/rootComponents/foo.js
The require would be:
require('./src/rootComponents/foo')
Note: This all assumes that the require()
statements are following System.js patterns/rules.
One other possible option is to provide a System.paths[]
option that creates an alias to a local path. I can't verify how/whether this'll work (ie I have never tried it) but the specifics can be found here