Project 'production' could not be found in workspace, when i build the angular project for production
10,537
It happened to me after upgrading from Angular 5 to Angular 6.
The solution is to replace in angular.json
:
"prod": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
},
with:
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
},
so basically it's just about renaming prod
to production
.
Related videos on Youtube
Author by
malikali
Updated on June 04, 2022Comments
-
malikali almost 2 years
I am new to Angular. I use this command
ng build --target=production --base-href /
, and here is the error that produces while build angular project for production.Project 'production' could not be found in workspace. Error: Project 'production' could not be found in workspace. at Workspace.getProject (/home/linux/Downloads/weather/node_modules/@angular-devkit/core/src/workspace/workspace.js:83:19) at Architect.getBuilderConfiguration (/home/linux/Downloads/weather/node_modules/@angular-devkit/architect/src/architect.js:96:41) at MergeMapSubscriber._loadWorkspaceAndArchitect.pipe.operators_1.concatMap [as project] (/home/linux/Downloads/weather/node_modules/@angular/cli/models/architect-command.js:77:55) at MergeMapSubscriber._tryNext (/home/linux/Downloads/weather/node_modules/rxjs/internal/operators/mergeMap.js:122:27) at MergeMapSubscriber._next (/home/linux/Downloads/weather/node_modules/rxjs/internal/operators/mergeMap.js:112:18) at MergeMapSubscriber.Subscriber.next (/home/linux/Downloads/weather/node_modules/rxjs/internal/Subscriber.js:103:18) at TapSubscriber._next (/home/linux/Downloads/weather/node_modules/rxjs/internal/operators/tap.js:109:26) at TapSubscriber.Subscriber.next (/home/linux/Downloads/weather/node_modules/rxjs/internal/Subscriber.js:103:18) at MergeMapSubscriber.notifyNext (/home/linux/Downloads/weather/node_modules/rxjs/internal/operators/mergeMap.js:141:26) at InnerSubscriber._next (/home/linux/Downloads/weather/node_modules/rxjs/internal/InnerSubscriber.js:30:21)
-
R. Richards almost 6 yearsDo you get the same error when you run
ng build --prod
, orng build --prod --base-href /
? -
malikali almost 6 yearsthanks R. Richards I have tried "ng build --prod --base-href /" and project successfully build.but Can you please tell the difference between the command I'm writing and yours.
-
R. Richards almost 6 yearsIt would seem that you cannot run the build with just a
target
, you have to include anenvironment
, too. This may be of some help to you. The docs don't explicitly state that you have to include both options, but it does read that way.
-