-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
No such built-in module commming from import-in-the-middle when using ts-node #12480
Comments
Hi, thanks for reporting, we'll take a look! |
It's a shame the stack trace from Node is so short and unhelpful! I can reproduce this but I can also work around it by reversing the order of the
This changes the order that the various ESM loader hooks are registered and therefore the order that they're called to resolve and load source code. |
By switching the order I get a different error: [Error: ENOENT: no such file or directory, open '/path-to-app/src/controllers/users.controller.js'] {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/path-to-app/src/controllers/users.controller.js'
}
import { UserController, ...otherControllers } from './controllers/index.js'; and export * from './users.controller.js';
// ... other controllers It's worth noticing that by switching the export * from './users.controller.ts';
// ... other controllers I have a bunch of imports so didn't update them all to try if the app runs correctly, will try it and share an update. Edit 1 It seems to be an issue with I updated all the: Edit 2 By updating the exports to be explicit, |
Any update on this? The |
Here's a repo on which the issue is reproduced. https://github.com/AnthonyDugarte/sentry-node-export-all-issue |
Found a monkeypatch, at https://github.com/DataDog/import-in-the-middle/blob/88605a707a63af9797986aa6a100161fe02aace6/hook.js#L169:
in order to generate the exports for a module that is star exporting ( But given that So the condition
the monkeypatch forces the tool to resolve relative paths to imports that are part of a typescript file ( |
by applying this patches provided here the app runs with star exports. |
With the newest release of If you upgrade to a fresh install of the latest version of the Node SDK it should use |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/node
SDK Version
8.9.1
Framework Version
Node v20.12.1
Link to Sentry event
No response
SDK Setup
Steps to Reproduce
Migrated from v7 to v8.
Added the @sentry/node/preload and it failed to run.
#12357 is similar but it's using
tsx
, the loaders order is wrong according to the thread; here I'm explicitly specifing the loaders order and I'm using ts-node with EMS. Usingtsx
is not negotiable given that they don't support the experimental legacy decorators.By following #12422, I was able to make it work using:
tsc --build && node --import @sentry/node/preload -r dotenv/config dist/index.js
; but that's by not usingts-node
, which is the issue I'm bringing up.Expected Result
No error
Actual Result
../ts-node.register.mjs
content is:The text was updated successfully, but these errors were encountered: