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. Markdown · JSON
Dual (CommonJS + ESM) Dual package — require() works on every Node.js version we test; import works too
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
- 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.
- TypeScript: npm install -D @types/proxy-from-env
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.0 | ✓ works | ✓ works |
How to import proxy-from-env
ES modules (import)
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 (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, corrected where a runtime test of that version contradicted them (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
Other dual (commonjs + esm) packages
- minimatch 10.2.6Dual
- brace-expansion 5.0.9Dual
- lru-cache 11.5.2Dual
- tslib 2.8.1Dual
- glob 13.0.6Dual
- eslint-visitor-keys 5.0.1Dual
- yallist 5.0.0Dual
- balanced-match 4.0.4Dual
Similar popularity
- require-directory 2.1.1CommonJS
- ts-api-utils 2.5.0Dual
- whatwg-mimetype 5.0.0CommonJS
- @eslint/eslintrc 3.3.7Dual
- doctrine 3.0.0CommonJS
- is-arrayish 0.3.4CommonJS
- tailwindcss 4.3.3Dual
- safer-buffer 2.1.2CommonJS