gpt4 book ai didi

angular - 当我构建用于生产的 Angular 项目时,在工作区中找不到项目 'production'

转载 作者:行者123 更新时间:2023-12-02 03:36:00 24 4
gpt4 key购买 nike

我是 Angular 新手。我使用这个命令ng build --target=production --base-href / ,这是在构建用于生产的 Angular 项目时产生的错误。

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)

最佳答案

从 Angular 5 升级到 Angular 6 后,我就遇到了这种情况。

解决方案是在angular.json中替换:

"prod": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
},

与:

"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
},

所以基本上就是将 prod 重命名为 product

关于angular - 当我构建用于生产的 Angular 项目时,在工作区中找不到项目 'production',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50191557/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com