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

Node22 under ESM, tsx running error? SyntaxError: The requested module '../a.js' does not provide an export named 'TestService'? #702

Open
4 tasks done
zurmokeeper opened this issue Feb 28, 2025 · 1 comment
Labels
bug Something isn't working pending triage

Comments

@zurmokeeper
Copy link

zurmokeeper commented Feb 28, 2025

Acknowledgements

  • I read the documentation and searched existing issues to avoid duplicates
  • I understand this is a bug tracker and anything other than a proven bug will be closed
  • I understand this is a free project and relies on community contributions
  • I read and understood the Contribution guide

Minimal reproduction URL

https://github.com/zurmokeeper/20250228-tsx-node22-bug

Problem & expected behavior (under 200 words)

Node v22.12.0 Executing npm run test in the root directory, reports an error.

SyntaxError: The requested module '../a.js' does not provide an export named 'TestService'

Not so under node 20.18.1, tsx version v4.19.3.

Image

@zurmokeeper zurmokeeper added bug Something isn't working pending triage labels Feb 28, 2025
@mtmacdonald
Copy link

mtmacdonald commented Feb 28, 2025

In a project with .js files that import ESM functions from .ts files (an old codebase) I'm also hitting SyntaxError: The requested module ... does not provide an export named ... errors.

Image

My codebase doesn't use "type": "module" in package.json yet. I am able to build and run the entrypoint with esbuild directly. I can also confirm the above error only happens in Node 22 or Node 23. But for Node 20, tsx handles this fine:

Image

Following.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending triage
Projects
None yet
Development

No branches or pull requests

2 participants