-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Consider to add .js extenstion to main entry point (bin/mocha) for better ES modules compatibility #4267
Comments
FYI I posted on nodejs/node#33223 that I actually believe this is a bug on node's side. mocha declares itself to be a commonjs module, not ESM, so node should not be attempting to load it as ESM. |
See #4298 for further discussion. |
@boneskull To clarify, the use-case is invoking the executable while passing
|
Ahh, yes, thanks. The recommended way would be to use
we should open an issue to look into the |
Is your feature request related to a problem or a nice-to-have?? Please describe.
Since extensionless files in ESM context was dropped in latest node versions, there is a problem problem using the
Mocha
with new esm-loaders like ts-node esm-loader, e.g.:node --loader ts-node/esm.mjs node_modules/mocha/bin/mocha --extension ts
causes error now:
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension "" for node_modules/mocha/bin/mocha
Describe the solution you'd like
Rename
bin/mocha
tobin/mocha.js
and add newbin/mocha
which simply requires newbin/mocha.js
(e.g.require('./mocha.js');
) for backward compatibility.Describe alternatives you've considered
n/a
Additional context
nodejs/node#31415
nodejs/node#33223 (comment)
The text was updated successfully, but these errors were encountered: