-
Notifications
You must be signed in to change notification settings - Fork 30k
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
regression in Node v12 with paths
#29139
Comments
I believe that's because your test script is launching node with
There was a bug that was fixed in the 12.0.0 release via #23683. I think that's what you're bumping into. |
That all makes sense, thank you for the quick response! |
`require.resolve` behavior was changed in Node v12 to comply with Node resolution algorithm (see nodejs/node#29139) - not sure why we thought this behavior was desirable in the first place (introduced in 3142f2e - probably cargo-culting `require.resolve`'s observed behavior) however, on legacy Node versions behavior appears unchanged if the current working directory is the same as `rootDir` - I didn't bother enforcing modern behavior because legacy isn't worth the effort in the process, fixed legacy detection
`require.resolve` behavior was changed in Node v12 to comply with Node resolution algorithm (see nodejs/node#29139) - not sure why we thought this behavior was desirable in the first place (introduced in 3142f2e - probably cargo-culting `require.resolve`'s observed behavior) however, on legacy Node versions behavior appears unchanged if the current working directory is the same as `rootDir` - I didn't bother enforcing modern behavior because legacy isn't worth the effort in the process, fixed legacy detection
require.resolve
)related issue: #27794 - but that was fixed in v12.3.0
Given the following directory structure:
On Node v8, v10 and v11, the following returned
/path/to/lib/dummy/src.js
, but Node v12 (all minor/patch releases) throws aMODULE_NOT_FOUND
exception ("Cannot find module 'dummy/src.js'"):(FWIW, I've automated bisecting Node versions: https://gist.github.com/FND/d35c5a5c128a7d0e9131ece904f601a9)
Node v12.8.0's stack trace looks interesting:
That
[eval]
bit seems suspect?Arguably v12's behavior is more correct (not sure why we expected
/path/to/lib/dummy
to be supported in the first place), but it's a behavioral change nonetheless. Since I couldn't find any relevant entries in Node's change log, I'm not sure whether this change was intentional.The text was updated successfully, but these errors were encountered: