canirequire › Dual (CommonJS + ESM) › proxy-from-env
Is proxy-from-env ESM-only? Can you require() it?
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. JSON
Dual (CommonJS + ESM) Dual package — both require() and import work
proxy-from-env publishes both a CommonJS entry and a native ESM entry (ESM added in 2.0.0). require("proxy-from-env") and import "proxy-from-env" both work on every supported Node.js version and in Bun.
Does proxy-from-env@2.1.0 actually load? Runtime test results
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 | ✓ works | ✓ works |
How to import proxy-from-env
ES modules (import)
import proxyFromEnv from "proxy-from-env";CommonJS (require)
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") and import "proxy-from-env" both work on every supported Node.js version and in Bun.
Can I require proxy-from-env?
Yes. proxy-from-env ships a CommonJS entry, so require("proxy-from-env") works on every Node.js version, alongside the native ESM entry for import.
Does proxy-from-env work in Bun?
Yes. import "proxy-from-env" loaded successfully in Bun 1.4 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
Other dual (commonjs + esm) packages
- minimatch 10.2.6Dual
- brace-expansion 5.0.9Dual
- lru-cache 11.5.2Dual
- glob 13.0.6Dual
- eslint-visitor-keys 5.0.1Dual
- yallist 5.0.0Dual
- balanced-match 4.0.4Dual
- js-yaml 5.4.1Dual
Similar popularity
- is-plain-obj 4.1.0ESM-only
- require-directory 2.1.1CommonJS
- ts-api-utils 2.5.0Dual
- whatwg-mimetype 5.0.0CommonJS
- doctrine 3.0.0CommonJS
- is-arrayish 0.3.4CommonJS
- tailwindcss 4.3.3Dual
- safer-buffer 2.1.2CommonJS