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
{{ message }}
Repository navigation
ts-node ./index may execute the wrong file extension because tsconfig search poisons the require.resolve cache #1220
Fixed in #1155, creating this issue as documentation.
In order to locate tsconfig files relative to entrypoint scripts, we use require.resolve to resolve the entrypoint's location on disk, then search from there. We do this resolution without knowing if --prefer-ts-exts is enabled or not. This means our initial resolution may resolve to index.js, even though we are supposed to execute index.ts.
require.resolve is cached. This means we may poison the cache with ./index.js. When we require('./index') it will be the wrong file.
The fix, implemented in #1155, is a hack which prevents node from caching our initial resolution.
Activity
make --script-mode the default; add --cwd-mode to switch back to old …
make --script-mode the default; add --cwd-mode to switch back to old …