Installation Methods
Review our alternate installation methods for Sentry using Nest.js.
Most node applications today are either written in or compiled to CommonJS (CJS), which uses require()
to load modules. Our recommended installation method when using CommonJS is to require the instrument.js
file at the top of your application. However, if your application is run in ECMAScript Modules (ESM) mode, this will not work, in which case you can follow the ESM docs.
Note that even if your application is written in ESM (using import
), it may still be run in CJS. In this case, you should follow the CommonJS instructions.
Nest.js transpiles to CJS by default, so you should follow the CommonJS installation instructions. Keep reading if you have a more customized application or build setup.
If you're using require()
in your application, you should follow the CommonJS instructions.
If you're using import
in your application, your installation method depends on how your application is run. If you compile your application (for example, into a /dist
folder or similar) before running it, you need to check how the compiled code looks like. Is the compiled code using require
? Then you should follow the CommonJS instructions. If the compiled code is using import
, you should follow the ESM instructions.
If you do not compile your code, you'll need to follow the ESM instructions.
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").