Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.12.0:npm (npm run prod) on project ui.frontend: Failed to run task: 'npm run prod' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 2 | Community
Skip to main content
May 10, 2024
Solved

Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.12.0:npm (npm run prod) on project ui.frontend: Failed to run task: 'npm run prod' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 2

  • May 10, 2024
  • 2 replies
  • 1127 views

Hi all, 

I am trying to run a Maven AEM project, but I got the below error. Specific reason after installing React JS inside ui.frontend. Can anyone help me with this? 

 

[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.12.0:npm (npm run prod) on project ui.frontend: Failed to run task: 'npm run prod' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 2 (Exit value: 2) -> [Help 1]

 

On Running npm run prod on ui.frontend

 

> aem-maven-archetype@1.0.0 prod

> webpack -p --config ./webpack.prod.js && clientlib --verbose

 

[webpack-cli] Error: Unknown option '-p'

[webpack-cli] Run 'webpack --help' to see available commands and options

 

 on my parent pom file.

 

 

 

 

<plugin> <groupId>com.github.eirslett</groupId> <artifactId>frontend-maven-plugin</artifactId> <version>${frontend-maven-plugin.version}</version> <configuration> <nodeVersion>v18.20.2</nodeVersion> <npmVersion>10.7.0</npmVersion> </configuration> <executions> <execution> <id>install node and npm</id> <goals> <goal>install-node-and-npm</goal> </goals> </execution> <execution> <id>npm ci</id> <goals> <goal>npm</goal> </goals> <configuration> <arguments>ci</arguments> </configuration> </execution> <execution> <id>npm install</id> <goals> <goal>npm</goal> </goals> </execution> </executions> </plugin>

 

 

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Rohan_Garg

Hey @ajithlalrg 

The problem seems to be with the webpack-cli command -

[webpack-cli] Error: Unknown option '-p'

 

Here's a suggestion for it -

Try changing the webpack-cli version from 4.x to 3.x 

I checked my project's repo and we are using webpack-cli version 3.x 

"webpack-cli": "^3.1.2",
"scripts": {
"dev": "webpack -d --env dev --config ./webpack.dev.js && clientlib --verbose",
"prod": "webpack -p --config ./webpack.prod.js && clientlib --verbose",
"start": "webpack-dev-server --open --config ./webpack.dev.js"
},

 

There is a known issue of -p argument not working with webpack v4.x though this was fixed in updating webpack-cli to 4+, is causing npm install to not work

 

References- https://stackoverflow.com/questions/65592541/webpack-when-run-in-terminal-it-gives-an-error-error-unknown-option-p

https://github.com/webpack/webpack-cli/issues/1934

 

Hope this helps!
Rohan Garg

2 replies

Rohan_Garg
Community Advisor
Rohan_GargCommunity AdvisorAccepted solution
Community Advisor
May 10, 2024

Hey @ajithlalrg 

The problem seems to be with the webpack-cli command -

[webpack-cli] Error: Unknown option '-p'

 

Here's a suggestion for it -

Try changing the webpack-cli version from 4.x to 3.x 

I checked my project's repo and we are using webpack-cli version 3.x 

"webpack-cli": "^3.1.2",
"scripts": {
"dev": "webpack -d --env dev --config ./webpack.dev.js && clientlib --verbose",
"prod": "webpack -p --config ./webpack.prod.js && clientlib --verbose",
"start": "webpack-dev-server --open --config ./webpack.dev.js"
},

 

There is a known issue of -p argument not working with webpack v4.x though this was fixed in updating webpack-cli to 4+, is causing npm install to not work

 

References- https://stackoverflow.com/questions/65592541/webpack-when-run-in-terminal-it-gives-an-error-error-unknown-option-p

https://github.com/webpack/webpack-cli/issues/1934

 

Hope this helps!
Rohan Garg