-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
-r/--require flag for npm modules #1803
Comments
I'm investigating. |
The problem is related to the fact that preload modules do not have a parent. Not even the main module. As such they don't use the |
Here's a potential fix I am evaluating: Module.preloadModules = function(requests) {
if (requests) {
// Preloaded modules have a dummy parent module which is deemed to exist
// in the current working directory. This seeds the search path for
// preloaded modules.
var parent = new Module('internal/preload', null);
parent.paths = Module._nodeModulePaths(process.cwd());
requests.forEach(function(request) {
Module._load(request, parent, false);
});
}
} Note the slight semantic difference between |
the same issue |
i want in cli i can use |
Right, but that seems to make sense, the requiring "module" in this case is effectively the working directory. |
@Fishrock123 That's my intuition too. I wanted to point it out to make sure it is not surprising to others. |
When the preload module is not a abs/relative path, we should use the standard search mechanism of looking into the node_modules folders outwards. The current working directory is deemed to be the 'requiring module', i.e. parent. The search path starts from cwd outwards. Fixes: nodejs#1803
When the preload module is not a abs/relative path, we should use the standard search mechanism of looking into the node_modules folders outwards. The current working directory is deemed to be the 'requiring module', i.e. parent. The search path starts from cwd outwards. Fixes: nodejs#1803
When the preload module is not a abs/relative path, we should use the standard search mechanism of looking into the node_modules folders outwards. The current working directory is deemed to be the 'requiring module', i.e. parent. The search path starts from cwd outwards. Fixes: #1803 PR-URL: #1812 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Fixed in 5759722! |
When the preload module is not a abs/relative path, we should use the standard search mechanism of looking into the node_modules folders outwards. The current working directory is deemed to be the 'requiring module', i.e. parent. The search path starts from cwd outwards. Fixes: nodejs/node#1803 PR-URL: nodejs/node#1812 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Using |
Given the following steps:
I get the following error:
My expectation was the module would be resolved the same way as if I were to do:
The text was updated successfully, but these errors were encountered: