Skip to content

Add common ESM errors to Troubleshooting page #1607

Description

@cspotcode

There are a few errors thrown by node -- and by our copy-pasted node code -- that confuse users. Add these to the troubleshooting page.

For example, when you try to require() a TS file and it's supposed to be executed as native ESM, the user gets a cryptic ERR_REQUIRE_ESM. When they try to do the same via import() instead of require() -- or node ./index.ts inside a type: module directory -- they get ERR_UNKNOWN_FILE_EXTENSION

Activity

  1. simonbuchan commented on Feb 3, 2022

    @simonbuchan

    Note the ERR_UNKNOWN_FILE_EXTENSION also happens with extensionless files, like require.resolve("mocha/bin/mocha") (which breaks ts-mocha at the moment).

  2. cspotcode commented on Feb 3, 2022

    @cspotcode
    CollaboratorAuthor

    Regarding ERR_UNKNOWN_FILE_EXTENSION and mocha's extensionless entrypoint:
    Linking to https://github.com/nodejs/node/discussions/41711 where the solution is being discussed. Once a solution is settled upon, ts-node can implement a workaround to mimic the fixed behavior on old node versions.

  3. added a commit that references this issue on Mar 7, 2022
    9769a59
  4. added this to the 10.8.0 milestone on Mar 7, 2022
  5. added a commit that references this issue on Mar 10, 2022
    ba95059
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    you can do thisGood candidate for a pull request.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions