Skip to content

Bug: tsx executes scripts in ESM context in Node 23.6 #10711

Closed
@abrahamguo

Description

@abrahamguo

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Issue Description

I've filed tsx#694, stating that tsx incorrectly executes scripts in an ESM context when "type": "commonjs" is present.

This causes types/tools/copy-ast-spect.ts to fail, because it tries to access __dirname, which is not defined in ESM context.
In turn, this means that yarn build fails.

Reproduction Repository Link

https://github.com/typescript-eslint/typescript-eslint

Repro Steps

  1. clone the repo
  2. yarn

Versions

package version
node 23.6.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workinglocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.repo maintenancethings to do with maintenance of the repo, and not with code/docs

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions