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

import.meta.resolve(pathToDirectory) returns a different result when running with tsx compared to node #480

Open
4 of 6 tasks
haines opened this issue Feb 22, 2024 · 0 comments
Labels
bug Something isn't working pending triage

Comments

@haines
Copy link

haines commented Feb 22, 2024

Acknowledgements

  • I searched existing issues before opening this one to avoid duplicates
  • I understand this is not a place for seek help, but to report a bug
  • I understand that the bug must be proven first with a minimal reproduction
  • I will be polite, respectful, and considerate of people's time and effort

Minimal reproduction URL

https://github.com/haines/tsx-import-meta-resolve

Version

v4.7.1

Node.js version

v20.11.1

Package manager

npm

Operating system

macOS

Problem & Expected behavior

I want to resolve the path to a directory within one of my dependencies. I'm using ESM so I call import.meta.resolve.

For example,

console.log(import.meta.resolve("typescript/lib"));

Doing this in node returns a file URL with the path to the directory:

file:///tsx-import-meta-resolve/node_modules/typescript/lib

However, when I run the script via tsx, I unexpectedly get a file URL with the path to index.js within the directory (which is a non-existent file):

file:///tsx-import-meta-resolve/node_modules/typescript/lib/index.js

Contributions

  • I plan to open a pull request for this issue
  • I plan to make a financial contribution to this project
@haines haines added bug Something isn't working pending triage labels Feb 22, 2024
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

1 participant