| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Adds a trailing slash to the current directory's path that's used as the second argument of `asyncESM.ESMLoader.import(specifier, pwd)`. Without the slash, relative paths will incorrectly resolve from one directory level higher up.
|
@eemeli thank you very much for your contribution! Seems like this was already fixed by #30609 and the modules team missed to have a look at this. I am very sorry about this, since this looks like great work! I hope to see further pull requests, since this one can not land anymore. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
There was a terminal / missing from the current path when calling import() from the REPL. This means that in a dir /foo/bar calling import('./dog.js') will look for /foo/dog.js, even though it should be looking for /foo/bar/dog.js.
Here's a minimal reproduction:
docker run -it --rm node:12.13.0 bash mkdir -p /tmp/foo/bar cd /tmp/foo/bar echo "console.log('Yes, this is dog')" > dog.js echo "import('./dog.js')" > call.js node --experimental-modules call.js (node:8) ExperimentalWarning: The ESM module loader is experimental. Yes, this is dog node --experimental-modules Welcome to Node.js v12.13.0. Type ".help" for more information. > (node:15) ExperimentalWarning: The ESM module loader is experimental. > import('./dog.js').then(console.log, console.error) Promise { <pending> } > Error: Cannot find module /tmp/foo/dog.js imported from /tmp/foo/bar at Loader.resolve [as _resolve] (internal/modules/esm/default_resolve.js:82:13) at Loader.resolve (internal/modules/esm/loader.js:73:33) at Loader.getModuleJob (internal/modules/esm/loader.js:147:40) at Loader.import (internal/modules/esm/loader.js:131:28) at vm.createScript.importModuleDynamically (repl.js:343:59) at processTicksAndRejections (internal/process/task_queues.js:93:5) at async importModuleDynamicallyWrapper (internal/vm/source_text_module.js:292:17) { code: 'ERR_MODULE_NOT_FOUND' } > import(path.resolve('./dog.js')).then(console.log, console.error) Promise { <pending> } > Yes, this is dog [Module] { default: {} }Checklist