---
title: "With a Bundler"
description: "Learn how to run your app with Sentry using a bundler plugin, without the --import flag."
url: https://docs.sentry.io/platforms/javascript/guides/pi-durable/install/bundler/
---

# With a Bundler for Pi Durable

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

If you build your server with a bundler, you can instrument your dependencies at build time with the Sentry bundler plugin instead of loading Sentry with the [`--import`](https://nodejs.org/api/cli.html#--importmodule) flag. Because the instrumentation is baked into your bundle, a plain top-level import of your instrument file is enough, and you can start your app with a regular `node` command, without the `--import` flag.

Use this method if you can't pass a command line flag to the Node.js binary, for example when your start command is fixed by your platform or process manager.

## [1. Create Your Instrument File](https://docs.sentry.io/platforms/javascript/guides/pi-durable/install/bundler.md#1-create-your-instrument-file)

Create a file named `instrument.(js|mjs)` in the root directory of your project that initializes Sentry:

```javascript
const Sentry = require("@sentry/node");
const { nodeProfilingIntegration } = require("@sentry/profiling-node");
Sentry.init({
  dsn: "https://<key>@o<orgId>.ingest.sentry.io/<projectId>",

  integrations: [
    // Add our Profiling integration
    nodeProfilingIntegration(),
  ],

  // Enables Tracing.
  // Set to 1.0 to capture 100% of spans for tracing.
  // We recommend reducing this value in production.
  tracesSampleRate: 1.0,

  // Enables Profiling for every session.
  profileSessionSampleRate: 1.0,
});
```

*Other available variations of the above snippet: ESM*

## [2. Add the Sentry Bundler Plugin](https://docs.sentry.io/platforms/javascript/guides/pi-durable/install/bundler.md#2-add-the-sentry-bundler-plugin)

Add the Sentry plugin for your bundler to your build configuration. The plugin instruments your dependencies at build time, so the SDK no longer depends on `Sentry.init()` running before your other imports.

```javascript
import { sentryVitePlugin } from "@sentry/node/vite";

export default {
  plugins: [sentryVitePlugin()],
};
```

*Other available variations of the above snippet: Rollup, webpack, esbuild*

## [3. Import Your Instrument File First](https://docs.sentry.io/platforms/javascript/guides/pi-durable/install/bundler.md#3-import-your-instrument-file-first)

Import `instrument.(js|mjs)` at the very top of your application's entry point, before any other imports:

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

// Now import other modules
import express from "express";

// Your application code goes here
```

## [4. Run Your App](https://docs.sentry.io/platforms/javascript/guides/pi-durable/install/bundler.md#4-run-your-app)

Start your application as usual. No `--import` flag is required, because the instrumentation is already part of your bundle:

```bash
node app.mjs
```

If you can't use a bundler, review our other [installation methods](https://docs.sentry.io/platforms/javascript/guides/pi-durable/install.md) for alternatives that don't rely on the `--import` flag.
