Open chrisandrewcl opened 1 month ago
Thanks for the issue. I appreciate the conciseness.
This is basically a duplicate of https://github.com/privatenumber/tsx/issues/96 because the root issue is that tsx doesn't lookup tsconfig.json
in imported packages.
I see this more of a feature request rather than a bug since TypeScript doesn't do this either.
As a workaround, after experimenting with a few other options, I got a working setup by ditching tscongif.json
's paths and using package.json
imports instead. Demo here.
P.S.: I am in a hurry, so I didn't update the file names in the demo repo, but everything is now working for tsc, tsx and esbuild.
Posting here to avoid making a duplicate issue because I believe I'm facing the same issue. If you'd like I can create a new issue.
tsx v4.16.0
node v22.3.0
[Running] npx tsx "e:\Documents\Code\NextJS\discord-collectibles-archive\discord-data\scripts\previews-extractor.ts"
node:internal/modules/run_main:115 triggerUncaughtException( ^ Error [ERR_MODULE_NOT_FOUND]: Cannot find package '~' imported from e:\Documents\Code\NextJS\discord-collectibles-archive\discord-data\scripts\previews-extractor.ts at packageResolve (node:internal/modules/esm/resolve:841:9) at moduleResolve (node:internal/modules/esm/resolve:914:18) at defaultResolve (node:internal/modules/esm/resolve:1119:11) at nextResolve (node:internal/modules/esm/hooks:750:28) at resolveBase (file:///C:/Users/admin/AppData/Roaming/nvm/v22.3.0/node_modules/tsx/dist/esm/index.mjs?1719846903563:2:3233) at async resolveDirectory (file:///C:/Users/admin/AppData/Roaming/nvm/v22.3.0/node_modules/tsx/dist/esm/index.mjs?1719846903563:2:3519) at async resolve (file:///C:/Users/admin/AppData/Roaming/nvm/v22.3.0/node_modules/tsx/dist/esm/index.mjs?1719846903563:2:4036) at async nextResolve (node:internal/modules/esm/hooks:750:22) at async Hooks.resolve (node:internal/modules/esm/hooks:238:24) at async handleMessage (node:internal/modules/esm/worker:199:18) { code: 'ERR_MODULE_NOT_FOUND' }
Node.js v22.3.0
For some reason, I can import an interface and assign it as a type with no problem. However, whenever I try to import an enum within the same type file that I imported for the previously mentioned interface I get an ERR_MODULE_NOT_FOUND
issue. Why is it that one import works but another doesn't? It's the exact same type declaration being imported.
Acknowledgements
Minimal reproduction URL
https://github.com/chrisandrewcl/tsx-dependency-paths
Problem & expected behavior (under 200 words)
No response
Bugs are expected to be fixed by those affected by it
Compensating engineering work financially will speed up resolution