I would like to load files dynamically in Node.js and this poses a problem that Node looks in node_modules
of the calling modules instead of looking in the node_modules
of file being loaded.
The reason I do not want to use require()
is because these are plugins and they can be included in the main app by simply being concatenating. So using require()
breaks the plugins. They have to be loaded directly into the main app context, but they have to have access to their local node_modules
as well.
I use vm.runInNewContext()
to evaluate the code. But how do I pass NODE_PATH
to runInNewContext()
?
_initPaths()
call. – Cellule