Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
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

Avatar

Level 1

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>

 

 

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

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

 

Hope this helps!
Rohan Garg

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

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

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

 

Hope this helps!
Rohan Garg