# @dotenv-run/esbuild

> Run your scripts with dotenv variables

Latest version **1.5.3** (published 2026-08-13) · ISC license · 0 weekly downloads

## Install

```sh
npm install @dotenv-run/esbuild
pnpm add @dotenv-run/esbuild
yarn add @dotenv-run/esbuild
bun add @dotenv-run/esbuild
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.5.3 |
| Published | 2026-08-13 |
| First published | 2023-10-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Chihab Otmani |
| Maintainers | chihab |
| Keywords | dotenv, run, cli |

## Links

- npm: https://www.npmjs.com/package/@dotenv-run/esbuild
- Homepage: https://github.com/chihab/dotenv-run
- npm.io page: https://npm.io/package/@dotenv-run/esbuild

## Dependencies (1)

- [@dotenv-run/core](https://npm.io/package/@dotenv-run/core.md) ^1.3.7

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 1.5.3 (latest) — 2026-08-13
- 1.5.2 — 2026-04-21
- 1.5.1 — 2025-06-28
- 1.5.0 — 2024-11-21
- 1.4.2 — 2024-10-13
- 1.4.0 — 2024-05-29
- 1.3.5 — 2024-03-31
- 1.3.4 — 2024-01-13
- 1.3.3 — 2024-01-11
- 1.3.2 — 2024-01-10
- 1.3.1 — 2024-01-10
- 1.3.0 — 2024-01-07
- 1.2.3 — 2023-11-22
- 1.2.2 — 2023-11-16
- 1.2.1 — 2023-11-13
- … 2 more at https://npm.io/package/@dotenv-run/esbuild/versions

## README

# @dotenv-run/esbuild

- ✅ Load environment variables from the command line `API_BASE=/v1/ node esbuild.mjs`
- ✅ Load environment variables from `.env` files
- ✅ Expand environment variables `API_URL=$API_BASE/users`
- ✅ Define environment variables for a specific environment (e.g. `.env.production`)
- ✅ Load priorities of `.env.*` files (e.g. `.env.production` > `.env`)
- ✅ Hierarchical cascading configuration in monorepo projects ([Nx](https://nx.dev), [Turbo](https://turborepo.com/), etc.)
  `apps/next-app/.env` > `apps/.env` > `.env`

## Install

```console
npm add @dotenv-run/esbuild --save-dev
```

## Usage

### Using define (recommended)

```js
import { build } from "esbuild";
import { env } from "@dotenv-run/esbuild";

const { full } = env({
  prefix: "MY_",
  verbose: false,
  files: [".env"],
});

const results = await build({
  bundle: true,
  write: false,
  entryPoints: [`test/app.js`],
  define: full,
});
```

### Using esbuild plugin

```js
import { build } from "esbuild";
import { dotenvRun } from "@dotenv-run/esbuild";

await build({
  write: false,
  bundle: true,
  entryPoints: [`test/app.js`],
  plugins: [
    dotenvRun({
      verbose: true,
      root: "../../",
      prefix: "^API",
    }),
  ],
});
```

---
_Source: https://npm.io/package/@dotenv-run/esbuild · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
