Hi Adobe Community,
I'm encountering an issue while building my AEM project using the AEM SDK (cloud version). I followed all the steps as per the documentation, but the build keeps failing at the ui.frontend module.
The error log shows:
It seems to be related to ES Modules not being compatible with require() in some part of the ui.frontend build, specifically during the execution of npm run prod.
Here’s what I’ve tried so far:
Running the build again using mvn -PautoInstallSinglePackage clean install
Updating node and npm versions
Removing node_modules and reinstalling
Ensuring compatibility with the AEM SDK version
Despite all this, the error persists. The rest of the modules build successfully; only the ui.frontend build fails.
Can anyone please help me understand what I might be missing or how to resolve
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @SaiSu5 ,
You're getting this error because your AEM project's frontend build is trying to use a newer JavaScript package (vargs) in an old way. The new version of vargs uses something called ES Modules, but your code is using the old require() method, which doesn’t work with that.
Downgrade vargs to an older version that still supports require().
In your package.json, change:
Delete node_modules and reinstall everything:
Use an older Node.js version like Node 16 or Node 18 instead of Node 22, because newer versions are stricter with how modules are handled.
Then try building again with:
The build fails because some tools are outdated and not ready for the latest JavaScript changes. Using older versions of vargs and Node.js usually solves the problem. Let me know if you want help updating your package.json!
Thanks & regards,
Vishal
Hi @SaiSu5 ,
You're getting this error because the vargs package you're using has been updated to a newer format called ES Modules, but your project is still trying to use the older require() method, which doesn’t work with the new format.
Use a different version of the vargs package — an older one that still works with require().
You can do this by updating your package.json to use an older version, like:
Remove vargs if you're not using it, or replace it with another package that works with your setup.
If you're writing custom code and using require('vargs'), change it to:
But this only works if your code is written using newer JavaScript syntax.
Basically, your code and the package are speaking different languages. You need to either downgrade the package or update your code, so both speak the same language. Let me know if you want help finding the right version!
Thanks & Regards,
Vishal
Basically, your code and the package are speaking different languages. You need to either downgrade the package or update your code so both speak the same language. Let me know if you want help finding the right version!
Hi Adobe AEM Community,
I’m working on an AEM project generated with the AEM Project Archetype, and I’m consistently facing a ERR_REQUIRE_ESM error during the frontend build phase (space.ui.frontend).
Command:
Error:
The error originates from:
Build Output:
UI Frontend build fails with:
Downgraded vargs to 0.1.0 in package.json to force CommonJS support.
Cleaned and reinstalled dependencies:
Tried patching clientlib-cli.js to use dynamic import() instead of require().
Added resolutions in package.json to force older compatible versions.
Verified build with mvn -X for full debug logs.
Despite these attempts, the error persists.
Is there an officially supported version of aem-clientlib-generator (or its dependencies) that works with the latest AEM SDK and avoids this ESM/CommonJS conflict?
Does Adobe recommend a specific workaround (downgrading vargs, using a patched version, or migrating to ESM) for projects using frontend-maven-plugin?
Is there a known fix or hotpatch to make clientlib-cli.js compatible with the latest Node.js environment?
Should I lock my Node.js version to an older LTS version (e.g., Node 14/16) to avoid this error?
Are there any updates in the AEM Project Archetype or aem-clientlib-generator addressing this issue?
AEM SDK: 2024.11.
Node.js: v22.18.0n
NPM: (10.93)
Maven: 3.9.11
OS: Windows 11
can any one help me with creation of my mvn project -space
Hi @SaiSu5 ,
You're getting this error because your AEM project's frontend build is trying to use a newer JavaScript package (vargs) in an old way. The new version of vargs uses something called ES Modules, but your code is using the old require() method, which doesn’t work with that.
Downgrade vargs to an older version that still supports require().
In your package.json, change:
Delete node_modules and reinstall everything:
Use an older Node.js version like Node 16 or Node 18 instead of Node 22, because newer versions are stricter with how modules are handled.
Then try building again with:
The build fails because some tools are outdated and not ready for the latest JavaScript changes. Using older versions of vargs and Node.js usually solves the problem. Let me know if you want help updating your package.json!
Thanks & regards,
Vishal
use
"aem-clientlib-generator": "1.8.2",
in your UI-frontend module's package.json
Hope this helps
UmeshThakur
@SaiSu5 Just checking in. Were you able to resolve your issue? We’d love to hear how things worked out. If the suggestions above helped, marking a response as correct can guide others with similar questions. And if you found another solution, feel free to share it — your insights could benefit the community. Thanks again for being part of the conversation!
Views
Replies
Total Likes
Views
Likes
Replies