angular - 为什么我在 Angular 10 中安装 ng-bootstrap 后立即出现构建错误?

标签 angular ng-bootstrap

我刚刚使用 Angular CLI 创建了一个全新的 Angular 10 项目,然后在设置我的初始模块和路由并测试它是否正常工作之后,我使用以下命令按照推荐添加了 ng-bootstrap:

ng 添加@ng-bootstrap/schematics

现在,当我尝试ng serve 我的项目时,出现以下错误:

Failed to compile entry-point @ng-bootstrap/ng-bootstrap (module as esm5) due to compilation errors:
../../node_modules/@ng-bootstrap/ng-bootstrap/rating/rating.js:148:43 - error NG1006: Cannot combine @Input decorators with query decorators

148         "starTemplate": [{ type: Input }, { type: ContentChild, args: [TemplateRef,] },],
                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../node_modules/@ng-bootstrap/ng-bootstrap/rating/rating.module.js:12:51 - error NG6001: The class 'NgbRating' is listed in the declarations of the NgModule 'NgbRatingModule', but is not a directive, a component, or a pipe. Either remove it from the NgModule's declarations, or add an appropriate Angular decorator.

12         { type: NgModule, args: [{ declarations: [NgbRating], exports: [NgbRating], imports: [CommonModule] },] },
                                                     ~~~~~~~~~

  ../../node_modules/@ng-bootstrap/ng-bootstrap/rating/rating.js:14:5
    14 var NgbRating = /** @class */ (function () {
           ~~~~~~~~~
    'NgbRating' is declared here.
../../node_modules/@ng-bootstrap/ng-bootstrap/rating/rating.js:14:5 - error NG6003: Appears in the NgModule.exports of NgbRatingModule, but could not be resolved to an NgModule, Component, Directive, or Pipe class.

Is it missing an Angular annotation?

14 var NgbRating = /** @class */ (function () {
       ~~~~~~~~~
../../node_modules/@ng-bootstrap/ng-bootstrap/rating/rating.module.js:7:5 - error NG6002: Appears in the NgModule.imports of NgbRootModule, but itself has errors

7 var NgbRatingModule = /** @class */ (function () {
      ~~~~~~~~~~~~~~~
../../node_modules/@ng-bootstrap/ng-bootstrap/rating/rating.module.js:7:5 - error NG6003: Appears in the NgModule.exports of NgbRootModule, but itself has errors

7 var NgbRatingModule = /** @class */ (function () {
      ~~~~~~~~~~~~~~~
../../node_modules/@ng-bootstrap/ng-bootstrap/rating/rating.module.js:7:5 - error NG6002: Appears in the NgModule.imports of NgbModule, but itself has errors

7 var NgbRatingModule = /** @class */ (function () {
      ~~~~~~~~~~~~~~~
../../node_modules/@ng-bootstrap/ng-bootstrap/rating/rating.module.js:7:5 - error NG6003: Appears in the NgModule.exports of NgbModule, but itself has errors

7 var NgbRatingModule = /** @class */ (function () {

这只是 ng-bootstrap 包中的错误,还是我在我的项目中做错了什么或我如何添加 ng-bootstrap?有什么修复建议吗?

最佳答案

在 GitHub 项目和 package.json 文件中进行大量挖掘尝试不同的东西之后,@ng-bootstrap/schematics 似乎是一个用于安装的过时包.通过从我的 package.json 文件中删除它并添加 "@ng-bootstrap/ng-bootstrap": "^6.0.0" 然后运行 ​​npm update 它解决了问题和我的项目再次工作。

关于angular - 为什么我在 Angular 10 中安装 ng-bootstrap 后立即出现构建错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62745680/

相关文章:

angularjs - 如何在 Angular2 中使用 Owl Carousel ?

javascript - ionic 2 中 Promise 函数内的 nav

javascript - 调用同一文件中的测试函数

angular - 当它是嵌套元素的一部分时,如何将 html 内容分配给 ngbPopover 和 popoverTitle?

javascript - 在 Angular 4 中使用 bootstrap 4 或 ng-bootstrap 组件

angular - 如何让 NativeScript 的 slider 使用步长值?

javascript - JavaScript 或 Angular4 中奇怪的三元条件

angular - ngx-datepicker header 为空

ng-bootstrap 警报不会关闭

ng-bootstrap - 如何在 ngb-pagination 中更改下一个文本、上一个文本