Skip to content
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

Add extension to bin files #4720

Closed
lachrist opened this issue Aug 14, 2021 · 2 comments
Closed

Add extension to bin files #4720

lachrist opened this issue Aug 14, 2021 · 2 comments
Labels
duplicate been there, done that, got the t-shirt... type: feature enhancement proposal

Comments

@lachrist
Copy link

Hi mocha team!

Using the --experimental-loader node flag with mocha bin will cause it to crash because it has no extension.

Example:

NODE_OPTIONS="--experimental-loader=./lib/loader.mjs" npx mocha
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension "" for .../mocha/bin/mocha

Explanation:

More specifically, the --experimental-loader flag will cause node to pick the esm loader to load bin/mocha and it does not like file without extensions (unlike the cjs loader).

Solution:

Add ".js" extension to bin/mocha which would still allow to create a symbolic link at .bin/mocha without file extension.

@lachrist lachrist added the type: feature enhancement proposal label Aug 14, 2021
@juergba juergba added the duplicate been there, done that, got the t-shirt... label Aug 14, 2021
@juergba
Copy link
Contributor

juergba commented Aug 14, 2021

@lachrist duplicate of #4645

Since --experimental-loader is still experimental and under redesign, we are not planning to add this extension to Mocha's binary for now. As a workaround you can move --experimental-loader=./lib/loader.mjs from NODE_OPTIONS to Mocha's config file .mocharc.js. Then Mocha will start a child-process with the entry point lib/cli/cli.js.

@lachrist
Copy link
Author

Sorry for the duplicate!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate been there, done that, got the t-shirt... type: feature enhancement proposal
Projects
None yet
Development

No branches or pull requests

2 participants