我正在尝试创建一个自定义模块,用于保存我的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。有人能告诉我错在哪里吗?