-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
require.resolve() fails with an empty options object #28077
Comments
This should be the fix: diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js
index 5cb88da189..98cfe02a97 100644
--- a/lib/internal/modules/cjs/loader.js
+++ b/lib/internal/modules/cjs/loader.js
@@ -601,10 +601,11 @@ Module._resolveFilename = function(request, parent, isMain, options) {
} else if (options.paths !== undefined) {
throw new ERR_INVALID_OPT_VALUE('options.paths', options.paths);
}
- } else {
- paths = Module._resolveLookupPaths(request, parent);
}
+ if (paths === undefined)
+ paths = Module._resolveLookupPaths(request, parent);
+
// Look up the filename first, since that's the cache key.
const filename = Module._findPath(request, paths, isMain);
if (!filename) { PR coming. |
3 tasks
cjihrig
added a commit
to cjihrig/node
that referenced
this issue
Jun 11, 2019
If require.resolve() is passed an options object, but the paths option is not present, then use the default require.resolve() paths. PR-URL: nodejs#28078 Fixes: nodejs#28077 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Yongsheng Zhang <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Anto Aravinth <[email protected]> Reviewed-By: James M Snell <[email protected]>
BridgeAR
pushed a commit
that referenced
this issue
Jun 17, 2019
If require.resolve() is passed an options object, but the paths option is not present, then use the default require.resolve() paths. PR-URL: #28078 Fixes: #28077 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Yongsheng Zhang <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Anto Aravinth <[email protected]> Reviewed-By: James M Snell <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In an empty directory, install lodash then from the REPL run the following commands. The second command fails if you pass an empty options object.
If the options value is
{}
or{ paths: undefined }
I would expect it to be ignored and the built-in defaults used.This issue breaks a few of my apps in node >= 12.3.
The text was updated successfully, but these errors were encountered: