Deferred Entrypoint for Koa
Learn about running Sentry without the --import flag.
Are you unsure if you should use this installation method? Review our installation methods.
If you can neither run your application with --import, nor use a bundler, you can use a deferred entrypoint to run your application with Sentry.
This assumes you've already created an instrument.mjs file that calls Sentry.init(), as shown in the quickstart.
Split the entrypoint in two. The static import runs Sentry.init(), and the dynamic import() loads your application afterwards, so your application's modules are wrapped:
main.mjsCopied
import "./instrument.mjs";
await import("./app.mjs");
import "./instrument.mjs";
await import("./app.mjs");
Your application code stays in app.mjs and needs no changes. Start it as usual:
Copied
node main.mjs
node main.mjs
Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").