# Is proxy-from-env ESM-only? Can you require() it?

> proxy-from-env@2.1.0 ships CommonJS and ESM builds. Dual package — require() works on every Node.js version we test; import works too.

Offers getProxyForUrl to get the proxy URL for a URL, respecting the *_PROXY (e.g. HTTP_PROXY) and NO_PROXY environment variables.

Last verified Sep 9, 2026 against proxy-from-env@2.1.0.

proxy-from-env publishes both a CommonJS entry and a native ESM entry (ESM added in 2.0.0). require("proxy-from-env") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js >=10. import "proxy-from-env" works alongside it.

## What to do

1. Nothing to change. require("proxy-from-env") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js >=10. import * as proxyFromEnv from "proxy-from-env" works alongside it; use named imports for what the ESM entry exports.
2. TypeScript: npm install -D @types/proxy-from-env

## Facts

- Latest: 2.1.0 (Mar 14, 2026)
- Module format: Dual (CommonJS + ESM)
- Last CommonJS version: 2.1.0
- Native ESM since: 2.0.0
- TypeScript types: @types/proxy-from-env
- Node engines: >=10
- Weekly downloads: 112.3M
- License: MIT

## Runtime test results for proxy-from-env@2.1.0

Installed and executed on Sep 9, 2026 with require("proxy-from-env") from a CommonJS file and import "proxy-from-env" from an ES module.

| Runtime | require("proxy-from-env") | import "proxy-from-env" |
|---|---|---|
| Node.js 18 | works | works |
| Node.js 20 | works | works |
| Node.js 22 | works | works |
| Node.js 24 | works | works |
| Node.js 26 | works | works |
| Bun 1.4.0 | works | works |

## How to import proxy-from-env

ES modules:

```js
import * as proxyFromEnv from "proxy-from-env";
```

Namespace import shown because the ESM entry may have no default export; use named imports for what it exports.

CommonJS:

```js
const proxyFromEnv = require("proxy-from-env");
```

## Module format by version

Derived from the type, main and exports fields of every stable release on npm (7 versions; the newest 7 shown).

| Versions | Format | First published |
|---|---|---|
| 2.1.0 | Dual (CommonJS + ESM) | Mar 14, 2026 |
| 2.0.0 | ESM-only | Feb 9, 2026 |
| 0.0.1 – 1.1.0 | CommonJS | Feb 18, 2016 |

## Frequently asked

**Is proxy-from-env ESM-only?**

proxy-from-env@2.1.0 ships CommonJS and ESM builds. proxy-from-env publishes both a CommonJS entry and a native ESM entry (ESM added in 2.0.0). require("proxy-from-env") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js >=10. import "proxy-from-env" works alongside it.

**Can I require proxy-from-env?**

Yes. proxy-from-env ships a CommonJS entry alongside the native ESM entry. require("proxy-from-env") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js >=10.

**Does proxy-from-env work in Bun?**

Yes. import "proxy-from-env" loaded successfully in Bun 1.4.0 on Sep 9, 2026.

**Does proxy-from-env ship TypeScript types?**

Not bundled. Install the community types with "npm install -D @types/proxy-from-env".

## Links

- [proxy-from-env on npm](https://www.npmjs.com/package/proxy-from-env)
- [Source repository](https://github.com/Rob--W/proxy-from-env)
- [HTML version](https://canirequire.com/package/proxy-from-env/)
- [JSON version](https://canirequire.com/package/proxy-from-env.json)

---

For scripts and AI agents: any package is at https://canirequire.com/package/<name>/index.md (Markdown) or https://canirequire.com/package/<name>.json (JSON); the site index is https://canirequire.com/llms.txt. Fetch the URL directly; no search needed.
