Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.3k
Closed
Labels
confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.source mapsIssues and PRs related to source map support.Issues and PRs related to source map support.
Description
- Version: v16.2.0
- Platform: Linux
What steps will reproduce the bug?
// index.jsimport{Something}from'./something.js';// something.js// Empty file, does NOT export `Something`// package.json{"type": "module"}To reproduce:
node index.js(throws a SyntaxError, this is expected behavior 👍)node --enable-source-maps index.js(throws TypeError [ERR_INVALID_URL], unexpected behavior 👎)
What is the expected behavior?
$ node index.js import{Something } from './something.js'; ^^^^^^^^^ SyntaxError: The requested module './something.js' does not provide an export named 'Something' at ModuleJob._instantiate (node:internal/modules/esm/module_job:121:21) at async ModuleJob.run (node:internal/modules/esm/module_job:171:5) at async Loader.import (node:internal/modules/esm/loader:178:24) at async Object.loadESM (node:internal/process/esm_loader:68:5) What do you see instead?
$ node --enable-source-maps index.js TypeError [ERR_INVALID_URL]: Invalid URL at __node_internal_captureLargerStackTrace (node:internal/errors:456:5) at __node_internal_addCodeToName (node:internal/errors:191:9) at new NodeError (node:internal/errors:363:5) at onParseError (node:internal/url:537:9) at new URL (node:internal/url:613:5) at getPackageScopeConfig (node:internal/modules/esm/resolve:177:24) at packageResolve (node:internal/modules/esm/resolve:657:25) at moduleResolve (node:internal/modules/esm/resolve:739:18) at Loader.defaultResolve [as _resolve] (node:internal/modules/esm/resolve:853:11) at Loader.resolve (node:internal/modules/esm/loader:89:40) at ModuleJob._instantiate (node:internal/modules/esm/module_job:137:31) at async ModuleJob.run (node:internal/modules/esm/module_job:171:5) at async Loader.import (node:internal/modules/esm/loader:178:24) at async Object.loadESM (node:internal/process/esm_loader:68:5){input: './package.json', code: 'ERR_INVALID_URL' Additional information
A cursory review tracked this to ModuleJob._instantiate in esm/module_job.js.
The code seems to expect a full path as the first element in the array, but when --enable-source-maps is on, the stack does not have this path.
As a result, the full error message is passed down into esm/resolve instead of a pathname, resulting in an Invalid URL.
neversun and matthiasgmoshest, shadab14meb346, bl-ue, ycjcl868, maxholman and 4 more
Metadata
Metadata
Assignees
Labels
confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.source mapsIssues and PRs related to source map support.Issues and PRs related to source map support.