-
Notifications
You must be signed in to change notification settings - Fork 28.3k
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
working directory makes require.resolve
fail with custom paths
on v8.x
#18686
Comments
If it works in Node 9, you probably are looking for the changes in 8578e81. It looks like it has been backported to the v8.x-staging branch. However, I don't see it in the upcoming 8.10.0 release proposal. |
Thanks @cjihrig; I'd looked through the changelog, but wasn't sure whether that commit was relevant. Is there a way I could confirm this fix by locally patching Node? I've extracted the v8.9.4 tarball, but can't find any relevant Also, should I pipe up in #18336, requesting inclusion after confirming the above? (I hesitate to just barge in there because I'm equally unfamiliar with Node's community processes.) |
@FND Did you download the binary tarball? You'll need the source tarball, JS files are in lib/. You can apply the patch by tacking on .patch (or .diff) to the commit URL Colin posted, i.e., https://github.com/nodejs/node/commit/8578e81b2b41eac6aea7a812b8e5f35a7362a6df.patch |
@bnoordhuis: You're right, thanks - I'd only checked the binary tarball because I had assumed 🤦♂️ mere JavaScript files didn't require compiling Node from source. After applying 8578e81, my test case above passes with the patched v8.9.4 binary - so @cjihrig was indeed correct. What's the next step for getting this backported for an LTS release? |
note that path resolution for third-party packages currently fails on Node v8 if CWD is not the same as `referenceDir`: nodejs/node#18686
note that path resolution for third-party packages currently fails on Node v8 if CWD is not the same as `referenceDir`: nodejs/node#18686
note that path resolution for third-party packages currently fails on Node v8 if CWD is not the same as `referenceDir`: nodejs/node#18686
8578e81 was backported to 8.10.0 as aaca447333. |
Invoking
require.resolve
with thepaths
option fails if the respective directory does not match the current working directory. This appears to have been fixed in v9.x, but continues to affect LTS versions.Reduced test case below - I hope these Bash one-liners are readily understandable, otherwise please let me know:
Setting
process.chdir("/tmp/test_case")
before invokingrequire.resolve
does not make any difference.On Node v9.5.0, both variants work as expected (i.e. just like variant B).
The text was updated successfully, but these errors were encountered: