-
-
Notifications
You must be signed in to change notification settings - Fork 35.8k
Support query parameters (and hash) in CLI paths #33163
Copy link
Copy link
Closed
Labels
esmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.stale
Metadata
Metadata
Assignees
Labels
esmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.stale
Type
Fields
Give feedbackNo fields configured for issues without a type.
Is your feature request related to a problem? Please describe.
I am interested in having my scripts respond to arguments supplied by the calling file, rather than for the application as a whole (i.e., checking the likes of
new URL(import.meta.url).searchParams.get('someParam')rather thanprocess.argv).This works well when a file imports another. In polyglot files too, it works to get the query string and hash in the browser (Chrome or Firefox at least) no matter whether the import originates in HTML or in JavaScript.
But I get a
MODULE_NOT_FOUNDerror when trying the likes of:node --experimental-modules index.mjs?someParam=1...apparently as it is looking for a file here rather than a (portion of) a URL.
Describe the solution you'd like
Allow the supplied file to be treated as a URL at least as far as the query string and any hash.
Describe alternatives you've considered
It duplicates effort to add special
process.argvhandling (and it could interfere if the same file is used in an application which has a different root file yet checksprocess.argvas well asimport.meta.url).Thanks!