---
title: "ESM Without CLI Flag"
description: "Learn about running Sentry in an ESM application, without the --import flag."
url: https://docs.sentry.io/platforms/javascript/guides/nestjs/install/esm-without-import/
---

# ESM Without CLI Flag | Sentry for Nest.js

Are you unsure if you should use this installation method? Review our [installation methods](https://docs.sentry.io/platforms/javascript/guides/nestjs/install.md).

When running your application in [ECMAScript Modules](https://nodejs.org/api/esm.html#introduction) (ESM) mode, you'll most likely want to [follow the ESM instructions](https://docs.sentry.io/platforms/javascript/guides/nestjs/install/esm.md). However, if you want to avoid using the `--import` command line option, for example, if you have no way of configuring a CLI flag, you can also follow an alternative setup that involves importing the `instrument.mjs` file directly in your application.

##### Restrictions of this installation method

This installation method has the fundamental restriction that only native Node.js APIs can be instrumented (such as `fetch` and the `http` module).

As a result, the Sentry SDK will **not** capture data from database calls, queues, ORMs, third-party libraries, or other framework-specific data.

We recommend using this only if the `--import` flag is not an option for you.

**Step 1:** Create a file named `instrument.mjs` that imports and initializes Sentry:

`instrument.mjs`

```javascript
import * as Sentry from "@sentry/nestjs";

// Ensure to call this before importing any other modules!
Sentry.init({
  dsn: "___PUBLIC_DSN___",

  // Add Tracing by setting tracesSampleRate
  // We recommend adjusting this value in production
  tracesSampleRate: 1.0,
});
```

**Step 2:** Import the `instrument.mjs` file before importing any other modules in your in the `main.ts` file of your application. This ensures that Sentry can automatically instrument all modules in your application:

`main.ts`

```javascript
// Import this first!
import "./instrument";

// Now import other modules
import { NestFactory } from "@nestjs/core";
// ...
// Your application code goes here
```
