-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
Improve module.createRequire documentation #28730
Comments
As stated in another documentation page, Also I think there is an error in the example code in the issue description:
IMHO that would probably be clearer to add an example using CJS, even though the function is more intended for ESM. |
The From fix cli imports PR
|
|
I think it's time to close this 2-year-old issue, anyone would be very welcome to open a PR to update |
Is your feature request related to a problem? Please describe.
The documentation was unclear for createRequire, I see #27758 & #27762 made a change and adds
import.meta.url
. I think this change adds difficulty (and needs more information) to understand this example.Also, the filename argument (path) can be a file, or URL. I don't understand why
../src/utils/
was changed toimport.meta.url
. It makes no sense to use createRequire with the module URL. And why rewrite "require" ?Describe the solution you'd like
Rewrite the example :
Describe alternatives you've considered
Another solution was: Add explain before the example and a link to
https://nodejs.org/api/esm.html#esm_import_meta
Second part :
Is your feature request related to a problem? Please describe.
The documentation was unclear for createRequire. I think the argument name path is more suited to filename in
module.createRequire(filename)
According to : "Must be a file URL object, file URL string, or absolute path string."Describe the solution you'd like
Change filename to path.
The text was updated successfully, but these errors were encountered: