Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ng build --prod Error: Unknown argument: prod

I have been running this command to build my project anytime i make changes:

ng build --prod --aot=false --build-optimizer=false

This has been working great until I made a mistake today. I ran npm i --save-dev @angular-devkit/build-angular under the /src/app folder by accident. I then ran npm uninstall @angular-devkit/build-angular under that folder and under the project root folder, and ran that npm i --save-dev @angular-devkit/build-angular under the root folder.

Now when I am trying to build the project with the first ng build command I provided above I get the Error: Unknown argument: prod.

When I run just ng build I get the following error:

This version of CLI is only compatible with Angular versions ^14.0.0, but Angular version 6.1.10 was found instead.

Any ideas as to how I can fix this?

like image 780
Omi in a hellcat Avatar asked Nov 24 '25 16:11

Omi in a hellcat


2 Answers

Your first error occurs because option --prod is removed in Angular 14 and deprecated since version 12, you can fix it by replacing it with --configuration "production"

See breaking changes in changelog for version 14: https://github.com/angular/angular-cli/blob/main/CHANGELOG.md#breaking-changes-2

Your second error is kind of self explaining, your CLI version is too new for the used Angular version. You could either try to upgrade one or downgrade the other.

If you upgrade your Angular version you might run into problems with other dependencies in your project and might also need to upgrade them.

like image 164
LeBavarois Avatar answered Nov 27 '25 12:11

LeBavarois


Test this command for building ng build --configuration production --aot instead of ng build --prod .

ng build --configuration production --aot

https://angular.io/guide/deprecations#angularcli

like image 37
Omid Sotooni Avatar answered Nov 27 '25 11:11

Omid Sotooni



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!