[英]Problem building poject with angular library. ng serve works fine locally Error message is Please add a @NgModule annotation
我已经建立了一个npm库https://www.npmjs.com/package/cloudee 。 它在本地工作正常,但是当我尝试构建部署时,出现此错误'/home/hadi/dev/rickithadi/node_modules/cloudee/cloudee.d.ts中的意外值'CloudyModule,该模块由/ home中的AppModule导入/hadi/dev/rickithadi/src/app/app.module.ts'。 请添加一个@NgModule注释。
一切正常,唯一的问题是当我执行build --aot --prod部署时。 我曾尝试在库和正在使用它的项目上降级角度版本。库最初是使用ng7和ng5中的项目构建的。 我还阅读了一些有关angular的文章,这些文章无法找到正确的angular版本并无法在ts.config.json中添加指向angular的路径。 这是行不通的。 我使用npm install --save cloudee安装了库。
app.module.ts
import {CloudyModule} from 'cloudee';
...
imports:[...CloudyModule
...]
项目的package.json
dependencies:[
"@angular/animations": "^5.2.11",
"@angular/cli": "~1.7.4",
"@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0",
"@angular/compiler-cli": "^5.2.0",
"@angular/core": "^5.2.0",
"@angular/forms": "^5.2.0",
"@angular/http": "^5.2.0",
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/router": "^5.2.0",
"cloudee":"0.05"
...
]
module.ts中导入的完整列表
@NgModule({
declarations: [
AppComponent,
NavbarComponent,
HomeComponent,
FooterComponent,
StuffComponent,
BlogComponent,
ContactComponent,
FieldErrorDisplayComponent,
SuccessComponent,
LoginComponent,
AdminComponent,
LiftingComponent,
TrackLiftComponent,
CustomRenderComponent,
ButtonViewComponent,
GainzComponent,
BlogDisplayComponent,
SafePipe
],
imports: [
CarouselModule.forRoot(),
TabsModule.forRoot(),
OrderModule,
Ng2SmartTableModule,
NgxEditorModule,
AngularFontAwesomeModule,
ModalModule.forRoot(),
HttpModule, NgPipesModule,
ReactiveFormsModule,
HttpClientModule,
FormsModule,
NgbModule.forRoot(),
BrowserAnimationsModule,
Ng5SliderModule,
CloudyModule,
BrowserModule,
RouterModule.forRoot(appRoutes)
],
entryComponents: [CustomRenderComponent, ButtonViewComponent],
providers: [AdminServiceService, AlwaysAuthGuard, OnlyLoggedInGuard],
bootstrap: [AppComponent]
})
库可以正常运行,唯一的错误是由模块“ / home / hadi / dev / rickithadi / src”中的模块“ AppModule”导入的“ /home/hadi/dev/rickithadi/node_modules/cloudee/cloudee.d.ts”中的“意外值” CloudyModule /app/app.module.ts'。 请添加一个@NgModule注释。 这不允许我部署。
在您的app.module.ts中使用@ngModule
import { NgModule } from "@angular/core";
@NgModule({
imports: [ CloudyModule ]
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.