-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
Dynamic import does not show location of SyntaxError #49441
Copy link
Copy link
Open
Labels
errorsIssues and PRs related to JavaScript errors originated in Node.js core.Issues and PRs related to JavaScript errors originated in Node.js core.esmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.promisesIssues and PRs related to ECMAScript promises.Issues and PRs related to ECMAScript promises.
Metadata
Metadata
Assignees
Labels
errorsIssues and PRs related to JavaScript errors originated in Node.js core.Issues and PRs related to JavaScript errors originated in Node.js core.esmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.promisesIssues and PRs related to ECMAScript promises.Issues and PRs related to ECMAScript promises.
Perform a dynamic import with
node -e "import('./syntax-error.mjs').catch(console.error)", the output does not help identify the error and could be seen by users as if node.js itself had a SyntaxError:Now create and run a loader.mjs script:
Running loader.mjs produces useful output:
I was not able to find a way to catch the error of a dynamic import and show the complete SyntaxError. Interestingly
node --unhandled-rejections=strict -e "import('./syntax-error.mjs')"or runningawait import('./syntax-error.mjs')fromnode --experimental-repl-awaitboth display the location of the SyntaxError.