Socket
Book a DemoInstallSign in
Socket

@dotenv-run/esbuild

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dotenv-run/esbuild

Run your scripts with dotenv variables

1.5.1
latest
npmnpm
Version published
Weekly downloads
5K
-32.85%
Maintainers
1
Weekly downloads
 
Created
Source

@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, Turbo, etc.) apps/next-app/.env > apps/.env > .env

Install

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

Usage

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

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",
    }),
  ],
});

Keywords

dotenv

FAQs

Package last updated on 28 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.