Since v2.33.0, the CLI crashes at startup with TypeError: e is not a constructor whenever HTTP_PROXY, http_proxy, HTTPS_PROXY, or https_proxy environment variables are set. This is a regression introduced by PR #1196 ("update proxy-agent to newer version"), which bumped proxy-agent from 6.5.0 → 8.0.1. v2.32.0 is unaffected.
Steps to Reproduce
- Set
HTTP_PROXY or HTTPS_PROXY (or their lowercase variants) in your environment
- Run any
openapi-generator-cli command:
HTTP_PROXY=http://proxy.example.com:3128 openapi-generator-cli generate \
-i openapi.yaml -g typescript-angular -o ./generated
- See error
Expected behavior
The CLI should start normally and proceed with code generation, as it did in v2.32.0.
Error shown
TypeError: e is not a constructor
at Array.<anonymous> (/…/node_modules/@openapitools/openapi-generator-cli/main.js:2:374)
at o (/…/node_modules/@openapitools/openapi-generator-cli/main.js:2:53914)
...
Node.js v20.20.2
Error: Process completed with exit code 1.
Operation System
- OS: Linux (self-hosted GitHub Actions runner), also reproducible on macOS
- Version: Ubuntu 22.04 / macOS
Package System
npm
Additional context
The bug is in apps/generator-cli/src/app/app.module.ts (introduced in commit 15a4632, PR #1196):
const ProxyAgent = require('proxy-agent').default ?? require('proxy-agent');
httpModuleConfig.httpAgent = new ProxyAgent(); // ← crashes
proxy-agent@6.5.0 exported the class directly, so require('proxy-agent') was the constructor. proxy-agent@8.0.1 changed to named exports ... require('proxy-agent') now returns { ProxyAgent, ... } with no .default property, so the ?? fallback returns the module object, and new on a plain object throws.
Since v2.33.0, the CLI crashes at startup with
TypeError: e is not a constructorwheneverHTTP_PROXY,http_proxy,HTTPS_PROXY, orhttps_proxyenvironment variables are set. This is a regression introduced by PR #1196 ("update proxy-agent to newer version"), which bumpedproxy-agentfrom6.5.0→8.0.1. v2.32.0 is unaffected.Steps to Reproduce
HTTP_PROXYorHTTPS_PROXY(or their lowercase variants) in your environmentopenapi-generator-clicommand:Expected behavior
The CLI should start normally and proceed with code generation, as it did in v2.32.0.
Error shown
Operation System
Package System
npm
Additional context
The bug is in
apps/generator-cli/src/app/app.module.ts(introduced in commit15a4632, PR #1196):proxy-agent@6.5.0exported the class directly, sorequire('proxy-agent')was the constructor.proxy-agent@8.0.1changed to named exports ...require('proxy-agent')now returns{ ProxyAgent, ... }with no.defaultproperty, so the??fallback returns the module object, andnewon a plain object throws.