Last active
June 2, 2016 00:10
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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