繁体   English   中英

当我构建用于生产的角度项目时,在工作区中找不到项目“生产”

[英]Project 'production' could not be found in workspace, when i build the angular project for production

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

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重命名为production

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM