canirequire

canirequireDual (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.

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

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.

Runtimerequire("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).

VersionsFormatFirst published
2.1.0Dual (CommonJS + ESM)Mar 14, 2026
2.0.0ESM-onlyFeb 9, 2026
0.0.1 – 1.1.0CommonJSFeb 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

Similar popularity