简体   繁体   English

Angular CLI v6:“未知选项:' - bh'”

[英]Angular CLI v6: “Unknown option: '--bh'”

Versions 版本

Angular CLI: 6.0.0
Node: 8.11.1
OS: win32 x64
Angular: 6.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.0
@angular-devkit/build-angular     0.6.0
@angular-devkit/build-optimizer   0.6.0
@angular-devkit/core              0.6.0
@angular-devkit/schematics        0.6.0
@angular/cdk                      6.0.1
@angular/flex-layout              6.0.0-beta.15
@angular/material                 6.0.1
@ngtools/webpack                  6.0.0
@schematics/angular               0.6.0
@schematics/update                0.6.0
rxjs                              6.1.0
typescript                        2.7.2
webpack                           4.6.0

Steps 脚步

Install Angular v6 / CLI v6

ng build --configuration=stage --bh /XYZ/

Error Unknown option: '--bh' 错误 未知选项:' - bh'

Observed behavior The build --bh CLI option does not work in v6 (or was removed?), however the documentation hasn't been updated to reflect the new way to build with 'base-href'? 观察到的行为build -bh CLI选项在v6中不起作用(或者已被删除?),但文档尚未更新以反映使用'base-href'构建的新方法?

Did you try using the full option name ? 您是否尝试使用完整选项名称?

ng build --configuration=stage --base-href /XYZ/

I'm using angular 6 and this still works. 我正在使用角度6,这仍然有效。 However I'm not sure if it's still meant to work in the future (cf this github issue ) 但是我不确定它是否仍然有意在将来工作(参见这个github问题

If the way above does not work, you can specify baseHref in your configurations section in your angular.json file 如果上面的方法不起作用,您可以在angular.json文件的configurations部分中指定baseHref

 "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {

          },
          "configurations": {
            "stage": {
              "optimization": true,
              "baseHref": "/XYZ/", //<=== here

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

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