Repository navigation
webpack-based dev-server crashing when loading ESM based proxy.conf.mjs #33652
Description
Activity
- addedgemini-triagedLabel noting that an issue has been triaged by geminiLabel noting that an issue has been triaged by gemini
on Jul 24, 2026 - changed the title
[-]webpack-based dev-server crashing hen loading ESM based proxy.conf.mjs[/-][+]webpack-based dev-server crashing when loading ESM based proxy.conf.mjs[/+]on Jul 24, 2026 It looks like you're running an unsupported Node.js version. Even though your
ng versionis correct, maybeng serveis being invoked from a different context? Modern Node versions allow loading.mjsmodules directly.The
ERR_REQUIRE_ESMerror is deprecated in Node.js v20.19.0, v22.12.0, or v23.0.0 and newer.Double-check which Node runtime is currently active in your environment.
Thx @alan-agius4 , as I already added above, my local Node version is v24.15.0 - so looks like pretty much well supported. Worth noting my package.json does not have any
typedefined (neithercommonjsnormodule).Maybe the deprecation of
ERR_REQUIRE_ESMdoesn't imply, as long not fully removed there won't be scenarios where this error code still is being returned? Hence the cleanup might be a bit early?I tested this locally and wasn't able to replicate the issue. In addition, we already have unit tests covering this scenario here: https://github.com/angular/angular-cli/blob/main/packages/angular/build/src/builders/dev-server/tests/options/proxy-config_spec.ts
I don't question this has been properly tested accordingly, also what you mentioned actually sounds quite logical. However, it's not just me getting this error, but all my team mates on the same setup are affected. So what else could be a reason for Node returning a deprecated error code other than it still could happen to be returned, regardless of the deprecation?
Looking at the Node.js source code https://github.com/nodejs/node/blob/9e6f8a04847c825bd0f0e4ea5990f98332a8c1a3/lib/internal/modules/esm/loader.js#L468, this error appears to only trigger when requiring ES modules is explicitly disabled.
I wouldn't know we explicitly disabled requiring ES modules or how to do that other than by adding
"type": "module"to package.json , which we didn't 🤔Additionally, as there's still 2 locations of this error-code in the Node sources, wouldn't this mean there still IS a chance it can be thrown?
These parts of the error message you posted above
Must use import to load ES Module:andrequire() of ES modules is not supported.have been bothering me quite a bit, as this wording was the error message that was displayed in older versions of Node.js.That error message has been changed years ago and I managed to find the PR nodejs/node#39175
If you, change the proxy to a CJS file, and console log,
process.versiondoes it show the expected version? I suspect that an old version is being used.Additionally, as there's still 2 locations of this error-code in the Node sources, wouldn't this mean there still IS a chance it can be thrown?
Only if require of ESM modules is disabled.
If you, change the proxy to a CJS file, and console log,
process.versiondoes it show the expected version? I suspect that an old version is being used.Output of
console.log(process.version)in renamed proxy.conf.js:v24.15.0angular-automatic-lock-bot commented
on Aug 27, 2026 More actionsThis issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.
- locked and limited conversation to collaborators
on Aug 27, 2026
Command
serve
Is this a regression?
The previous version in which this bug was not present was
20
Description
We're on upgrading our mono-repo hosting several Angular apps from NG20 to NG21, where some apps are using esbuild-based application-builder and some are still stuck with webpack.
For the webpack based apps, we encounter an error crashing the local (ssr) dev-server on startup:
As to be seen in the above message, the proxy-config we're using is in ESM format.
application-builder/ esbuild based dev-server seems not being affected.
I tried to debug the issue and tracked it down to the following location:
node_modules/@angular/build/src/utils/load-proxy-config.js:https://github.com/angular/angular-cli/blob/21.0.x/packages/angular/build/src/utils/load-proxy-config.ts#L57
The above logic will throw on any error with a different code than
ERR_REQUIRE_ASYNC_MODULE, but in my case the error code isERR_REQUIRE_ESM.Looking at the v20 version of
https://github.com/angular/angular-cli/blob/20.3.x/packages/angular/build/src/utils/load-proxy-config.ts#L69
the additional error code is still present
After locally patching
node_modules/@angular/build/src/utils/load-proxy-config.jsdev-server started working again with a fully functional proxy config.So I'm requesting to add the error code back to make webpack-based dev servers with esm proxy configs working again. Thx in advance!
Minimal Reproduction
Exception or Error
Your Environment
Anything else relevant?
No response