Skip to content

Instantly share code, notes, and snippets.

@pospi
Last active June 2, 2016 00:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pospi/db256725b3210cc362051cb38b280a16 to your computer and use it in GitHub Desktop.
Save pospi/db256725b3210cc362051cb38b280a16 to your computer and use it in GitHub Desktop.
nodejs module system hack to add a module's include paths to global include paths.
// Usage: from your entrypoint script file or other 'global' module of interest:
// require('nodejs-global-module-includes')(module);
var Module = require('module');
export default function setModuleIncludePathGlobal(globalModule) {
var globalPaths = globalModule.paths;
var oldPathHandler = Module._nodeModulePaths;
Module._nodeModulePaths = function(from) {
return oldPathHandler(from).concat(globalPaths);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment