Expand my Community achievements bar.

Adobe Summit 2025: AEM Session Recordings Are Live! Missed a session or want to revisit your favorites? Watch the latest recordings now.

NPM error during mvn clean install code is run

Avatar

Level 2

Hi Community,
I have created a project in aem and during the maven build and project deployment I am getting an npm error.

RekhaRa4_0-1746042732941.png

The versions I have checked and updated as per the version available in system. 

RekhaRa4_1-1746042906272.pngRekhaRa4_2-1746042980634.pngRekhaRa4_3-1746043033269.png

The specific error is:

"Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.11.0:npm (npm run-script build) on project aem-guides.ui.frontend: Failed to run task: 'npm run-script build' failed" - and the maven build is failing. Can anyone please provide some insights.

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

4 Replies

Avatar

Community Advisor

Hi @RekhaRa4,

Can you try below steps:

  1. Run the frontend build manually to see the real cause:
    cd ui.frontend
    npm install
    npm run build

    This will likely show a more descriptive error like a missing dependency, syntax error, or misconfigured Webpack plugin.

  2. Missing dependencies: Run npm install to ensure all dependencies are downloaded.
  3. Scripts in package.json: Ensure build script is correctly defined.

  4. Sometimes corrupted node_modules or lock files can cause issues:

    rm -rf node_modules package-lock.json
    npm cache clean --force
    npm install
    npm run build

Please refer similar issues: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/failed-to-execute-goal-com...

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/help-failed-to-execute-goa...

 

Hope that helps!


Santosh Sai

AEM BlogsLinkedIn


Avatar

Community Advisor

Hi @RekhaRa4 ,

Thanks for sharing the images and context. The key error you're encountering is:

Failed to run task: 'npm run-script build' failed.

This indicates the npm run build command inside the ui.frontend module is failing, but Maven doesn’t show exactly why. Here's how you can resolve it:

1. Run Build Manually

Go to the frontend directory and run the build manually:

cd ui.frontend
npm install
npm run build

This should show the exact error (e.g., missing dependencies, syntax errors, config issues).

2. Clean Cache and Reinstall

Sometimes node_modules or lock files cause weird issues:

rm -rf node_modules package-lock.json
npm cache clean --force
npm install
npm run build

3. Check Your package.json

Make sure scripts.build is defined correctly in ui.frontend/package.json, like:

"scripts": {
  "build": "webpack --mode production"
}

If the build script is missing or broken, it will fail.

4. Node/NPM Compatibility

You are using:

Node: v22.9.0

NPM: 10.8.3

These are very new versions and may cause issues with some dependencies. Consider using a more stable version like:

Node: 16.x or 18.x

NPM: 8.x or 9.x

You can use Node Version Manager (nvm) to easily switch versions:

nvm install 18
nvm use 18

Then try the build again.

Regards,
Amit

Avatar

Community Advisor

Hi @RekhaRa4 ,

Actual error message displayed  above the message SUCCESS/SKIPPED message, the error message displayed in the screenshot is error code. If you can share the first error message which are not displayed in screenshot, people may be able to help more accurately.

Thanks

Avatar

Level 2

Hi @SantoshSai , @AmitVishwakarma - Thanks for your suggestions, I have tried using these, but the error still persists - some dependencies I was able to resolve but still this error persists. I just did a mvn build and found two new errors:

"npm test failed" and "autoInstallPackage command not recognized"

Both of these errors are appearing whenever I am trying to run the mvn clean install -PautoInstallPackage command. Would like to get some more suggestions or maybe next steps.