Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards.
SOLVED

Error: Maven Project Build Failed in ui.frontend for AEM SDK Cloud

Avatar

Level 2

SaiSu5_0-1754167917181.png

 

 

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:

 

javascript
CopyEdit
Error [ERR_REQUIRE_ESM]: require() of ES Module ...\node_modules\vargs\index.mjs not supported. Instead change the require of ...\vargs\index.mjs to a dynamic import() which is available in all CommonJS modules.
 

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

1 Accepted Solution

Avatar

Correct answer by
Level 4

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.

What you can do to fix it:

  1. Downgrade vargs to an older version that still supports require().
    In your package.json, change:

    json
     
    "vargs": "0.1.0"
  2. Delete node_modules and reinstall everything:

    bash
     
    rm -rf node_modules package-lock.json npm install
  3. 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.

  4. Then try building again with:

    bash
     
    mvn clean install -PautoInstallSinglePackage

In short:

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

View solution in original post

5 Replies

Avatar

Level 4

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.

How to fix this:

  1. 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:

    json:
     
    "vargs": "0.1.0"
  2. Remove vargs if you're not using it, or replace it with another package that works with your setup.

  3. If you're writing custom code and using require('vargs'), change it to:

     
    js:
    const vargs = await import('vargs');

    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!

Avatar

Level 2

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).


Error Details

  • Command:

    bash
    Copy code
    mvn clean install
  • Error:

    vbnet
    Copy code
    Error [ERR_REQUIRE_ESM]: require() of ES Module ...\node_modules\vargs\index.mjs is not supported.

    The error originates from:

    python
    Copy code
    ...\node_modules\aem-clientlib-generator\bin\clientlib-cli.js
  • Build Output:
    UI Frontend build fails with:

    vbnet
    Copy code
    [ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.12.0: npm (npm run prod) on project space.ui.frontend

What I Have Tried

  1. Downgraded vargs to 0.1.0 in package.json to force CommonJS support.

  2. Cleaned and reinstalled dependencies:

    bash
    Copy code
    rm -rf node_modules package-lock.json npm install
  3. Tried patching clientlib-cli.js to use dynamic import() instead of require().

  4. Added resolutions in package.json to force older compatible versions.

  5. Verified build with mvn -X for full debug logs.

Despite these attempts, the error persists.


My Questions

  1. 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?

  2. Does Adobe recommend a specific workaround (downgrading vargs, using a patched version, or migrating to ESM) for projects using frontend-maven-plugin?

  3. Is there a known fix or hotpatch to make clientlib-cli.js compatible with the latest Node.js environment?

  4. Should I lock my Node.js version to an older LTS version (e.g., Node 14/16) to avoid this error?

  5. Are there any updates in the AEM Project Archetype or aem-clientlib-generator addressing this issue?


Environment Details

  • 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

 

Avatar

Correct answer by
Level 4

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.

What you can do to fix it:

  1. Downgrade vargs to an older version that still supports require().
    In your package.json, change:

    json
     
    "vargs": "0.1.0"
  2. Delete node_modules and reinstall everything:

    bash
     
    rm -rf node_modules package-lock.json npm install
  3. 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.

  4. Then try building again with:

    bash
     
    mvn clean install -PautoInstallSinglePackage

In short:

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

Avatar

Community Advisor

use 

"aem-clientlib-generator": "1.8.2",

in your UI-frontend module's package.json

Hope this helps

UmeshThakur

Avatar

Administrator

@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!



Kautuk Sahni