未捕获错误:Type MyModule没有'ɵmod'属性。

4

我正在尝试创建一个自定义模块,用于保存我的UI组件。我需要它与Angular 10及以上版本兼容。我的库的package.json如下:

{
  "name": "myLibModule",
  "version": "0.0.15",
  "peerDependencies": {
    "@angular/core": "^10.2.5",
    "@angular/common": "^10.2.5",
    "@angular/material": "^10.2.7",
    "@angular/router": "^10.2.5"
  },
  "dependencies": {
    "tslib": "^2.0.0"
  }
}

增强我的模块:

import { NgModule } from '@angular/core';
import { HeaderComponent } from './components/header/header.component';
import { NotificationTrayComponent } from './poettinger-notifications/components/notification-tray/notification-tray.component';
import { CommonModule } from '@angular/common';
import { NotificationComponent } from './poettinger-notifications/components/notification/notification.component';
import { NgbProgressbarModule } from '@ng-bootstrap/ng-bootstrap';

@NgModule({
    declarations: [HeaderComponent, NotificationTrayComponent, NotificationComponent],
    imports: [
        CommonModule,
        NgbProgressbarModule
    ],
    exports: [HeaderComponent, NotificationTrayComponent]
})
export class NgxPoettingerComponentsModule { }

现在我试图在我的Angular应用程序中使用它,该应用程序具有以下package.json:

{
  "name": "libtest",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~12.2.0",
    "@angular/cdk": "^12.2.13",
    "@angular/common": "~12.2.0",
    "@angular/compiler": "~12.2.0",
    "@angular/core": "~12.2.0",
    "@angular/forms": "~12.2.0",
    "@angular/material": "^12.2.13",
    "@angular/platform-browser": "~12.2.0",
    "@angular/platform-browser-dynamic": "~12.2.0",
    "@angular/router": "~12.2.0",
    "@it-entwicklung/ngx-poettinger-components": "file:../lib-workspace/dist/myLibModule",
    "rxjs": "~6.6.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~12.2.13",
    "@angular/cli": "~12.2.13",
    "@angular/compiler-cli": "~12.2.0",
    "@types/jasmine": "~3.8.0",
    "@types/node": "^12.11.1",
    "jasmine-core": "~3.8.0",
    "karma": "~6.3.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "~1.7.0",
    "typescript": "~4.3.5"
  }
}

我遇到了以下错误:
Uncaught Error: Type NgxPoettingerComponentsModule does not have 'ɵmod' property.
    at getNgModuleDef (core.js:1131:1)
    at recurse (core.js:25285:1)
    at recurse (core.js:25296:1)
    at registerNgModuleType (core.js:25281:1)
    at new NgModuleFactory$1 (core.js:25395:1)
    at compileNgModuleFactory__POST_R3__ (core.js:29094:1)
    at PlatformRef.bootstrapModule (core.js:29344:1)
    at Module.4431 (main.ts:11:26)
    at __webpack_require__ (bootstrap:19:1)
    at __webpack_exec__ (log$:23:1)

我在生产模式下编译它时没有使用Ivy。有人能告诉我错在哪里吗?
1个回答

1

看起来你在 NgxPoettingerComponentsModule 模块的导入部分缺少一些内容。我猜测你有一些组件/管道/服务应该在导入部分,但目前它们在模块的声明部分或导入部分。

如果你能在这里发布你的模块,那就更好了。


谢谢您的回答,我已经将模块文件添加到问题中。 - Georg Edlbauer

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接