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

Improve error message when module.register is missing #682

Open
5 of 6 tasks
SebastienGllmt opened this issue Dec 6, 2024 · 2 comments
Open
5 of 6 tasks

Improve error message when module.register is missing #682

SebastienGllmt opened this issue Dec 6, 2024 · 2 comments
Labels
bug Something isn't working pending triage

Comments

@SebastienGllmt
Copy link

SebastienGllmt commented Dec 6, 2024

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

denoland/deno#23201

Problem & expected behavior (under 200 words)

Deno does not support module.register as seen here

The current error message when module.register is missing is a little misleading. It mentions you're using the wrong node version (see here), but actually you're not running nodejs at all

It should probably say something like

Version ${process.version} of your runtime does not support module.register(). If you are using Node.js, upgrade to Node v18.19 or v20.6 and above.

If you're wondering how process.version even works at all on Deno, it's because Deno pretends it is running Node 22.10.0 just to make sure it doesn't crash on any library that depends on process.version

Bugs are expected to be fixed by those affected by it

  • I'm interested in working on this issue

Compensating engineering work will speed up resolution and support the project

  • I'm willing to offer $10 for financial support
@SebastienGllmt SebastienGllmt added bug Something isn't working pending triage labels Dec 6, 2024
SebastienGllmt added a commit to SebastienGllmt/tsx that referenced this issue Dec 6, 2024
@privatenumber
Copy link
Owner

tsx is specifically designed for Node.js, and the compatible versions are clearly stated: https://github.com/privatenumber/tsx/blob/master/package.json#L69-L71.

Given this, I don't think it makes sense to include code that handles non-Node environments. This is especially unnecessary considering other environments like Deno and Bun already have built-in support for types.

Managing compatibility with alternative runtimes should be the responsibility of the libraries using tsx, not tsx itself.

@SebastienGllmt
Copy link
Author

Generally speaking I agree which is why I only changed the error message instead of doing any kind of env variable checking to figure out which environment it is

A lot of projects use tsx as you know so it's inevitable that somebody will run tsx in a different runtime even if unintentionally through a dependency (that was my case)

It's totally fine not to merge this - just the fact that when you search Deno in this repo this issue comes up is probably enough to unblock anybody else that runs into this issue without having to actually commit anything to the repo

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