The Error “ng build –prod Error: Unknown argument: prod”, is an error that is invoked when you are coding on angular and are trying to run certain commands (like ng build –prod –aot=false –build-optimizer=false) in your project file.
Given below is the snippet of the error you might get:
ng build --prod Error: Unknown argument: prod
I would like to share with you the steps I took to fix the “ng build –prod Error: Unknown argument: prod”
The error, “ng build –prod Error: Unknown argument: prod” is seen because option —prod was deprecated in version Angular 12 and removed in Angular 14, but it can be fixed by substituting —configuration “production” for the command you are using.
You can also get the error if you just run ng build command , the error ng build –prod Error: Unknown argument: prod occurs because the used Angular version is incompatible with the CLI version.
Either downgrade the version you are using or attempt to upgrade it.
In case you update your Angular version in your project, you can have issues with other project dependencies and need to upgrade them as well for everything to work smoothly.
To fix the error, “ng build –prod Error: Unknown argument: prod” you will have to substitute —configuration “production” for the command you are using which is causing the error.
Or to fix the error ng build –prod Error: Unknown argument: prod, either downgrade the angular version you are using or upgrade it to the latest version to fix the error.
You can follow the below mentioned steps to fix the error, “ng build –prod Error: Unknown argument: prod”:
First, you will have to know that option —prod was deprecated in version 12 and removed in Angular 14, but it can be fixed by substituting —configuration “production” for the command you are using .
You can also get the error if you just run ng build command , the error occurs because the used Angular version is incompatible with the CLI version.
Either downgrade the version you are using or attempt to upgrade it.
This should fix the error “ng build –prod Error: Unknown argument: prod”.
Conclusion
To fix the error, “ng build –prod Error: Unknown argument: prod” you will have to substitute —configuration “production” for the command you are using which is causing the error.
If you are still facing the error then you will have to either downgrade the version you are using or attempt to upgrade it.