【问题标题】:Why am I getting Build Errors immediately after installing ng-bootstrap in Angular 10?为什么在 Angular 10 中安装 ng-bootstrap 后立即出现构建错误?
【发布时间】:2020-10-25 23:09:36
【问题描述】:

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

ng add @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 的?有什么修复它的建议吗?

【问题讨论】:

标签: angular ng-bootstrap


【解决方案1】:

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

【讨论】:

  • 这对我也很有效。我不知道为什么,但我几乎从来没有使用带有原理图的“ng add”......感谢这篇文章!
猜你喜欢
  • 2017-06-12
  • 2014-02-26
  • 2020-06-06
  • 2021-11-05
  • 1970-01-01
  • 2021-05-06
  • 1970-01-01
  • 2017-04-16
  • 1970-01-01
相关资源
最近更新 更多