Skip to content

Error when tsconfig.compilerOptions.module is unsupported by Node #1069

Open

Description

@alcuadrado

Desired Behavior

Throw an error if tsconfig.compilerOptions.module is other than "commonjs".

Is this request related to a problem?

I have a command-line application that loads ts-node if it's installed. Users can use typescript for almost everything in that case.

The problem is that some users may accidentally set the tsconfig.compilerOptions.module to incompatible values. If this happens, the errors they get are pretty hard to understand.

Alternatives you've considered

We could validate this ourselves, but that would mean reimplementing how ts-node chooses which tsconfig.json to use.

Additional context

This request should be updated if ts-node were to support the new native ESM mode of node.

Activity

  1. cspotcode commented on Jul 9, 2020

    @cspotcode
    Collaborator

    Some relevant info:

    ts-node already supports native ESM. See #1007 for discussion.

    We default to CommonJS if the user does not specify the module option.
    https://github.com/TypeStrong/ts-node/blob/master/src/index.ts#L912-L915
    But we respect the user's choice if they configure it.

  2. added this to the next milestone on May 15, 2021
  3. modified the milestones: 10.2.0, next on Aug 8, 2021
  4. removed this from the 10.5.0 milestone on Feb 2, 2022
  5. nicolas377 commented on Jul 8, 2022

    @nicolas377

    Should this be a warning? While we know that node will probably throw when running whatever unsupported module type, we can't be 100% future proof with that. IMHO, it's a better idea to warn the user of the upcoming error than completely cut them off.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions