Skip to content

Add extension to bin files #4720

@lachrist

Description

@lachrist

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicatebeen there, done that, got the t-shirt...type: featureenhancement proposal

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions