-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
Experimental module resolution inconsistency between --eval and file #28160
Comments
cc @nodejs/modules |
This is expected behavior. If Fluture’s
This I think is a bug, since the following prints an inspection of node --experimental-modules --input-type=commonjs \
--eval 'const Fluture = require("fluture"); console.log(Fluture)' The expected behavior for your first shell command ( |
So the reason for the bug here is likely due to the fact that the evaluated module is given a unique ID The fix would likely be to change this default ID form to something cwd-like so eg - It would literally be that exact one liner at that link linked to above to fix! |
That sounds like the same overall approach that is used for CommonJS:
|
The test to fix this should be whether the context path for the current module exists. |
This has been fixed in #28389. |
v12.3.1
Linux thinkpad-avaq 4.19.47 #1-NixOS SMP Fri May 31 13:46:35 UTC 2019 x86_64 GNU/Linux
Preparation
cd $(mktemp -d)
.js
main file as well as a.mjs
main file:npm install fluture@11.0.1
Reproducing
Run the following two shell scripts:
node --input-type=module \ --experimental-modules \ --eval 'import Future from "fluture"; console.log(Future)'
Expected result
The output of both shell scripts is the same.
Actual result
The first script errors with
Error: Cannot find package 'fluture' imported from
, and the output from the second shows that the module resolver loaded the CommonJS version of the package into the module./cc @ljharb
The text was updated successfully, but these errors were encountered: