You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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:
Looking at that PR 672, Only some of the tests are failing; tests for node v22.14.0 are already included some of which are passing and some of which are failing. Tests with node version 22.6.0 are passing. So there is some support for Node v22 just not the current LTS version.
Through experimentation I think it can be seen that this bug was caused by a change in Node v22.10.0: that is; my code works with Node 22.9.0 but fails with the above error when run with Node 22.10.0
This is when trying to import from *.cjs in to an ESM module (*.ts with type: module)
The code compiles/builds with tsc, its only when it runs under mocha with tsx for unit tests that this bug occurs.
Acknowledgements
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.
The text was updated successfully, but these errors were encountered: