**中的错误不是NgModule [英] ERROR in ** is not an NgModule
问题描述
我有这个NgModule:
I have this NgModule:
@NgModule({
imports: [
CommonModule
],
exports: [
SP21LoadingBar
],
declarations: [SP21LoadingBar]
})
export class SP21LoadingBarModule { }
客户告诉我
ERROR in SP21LoadingBarModule is not an NgModule
请注意:如果我接受代码并将其放入我的项目中,它将可以正常工作.但是,一旦我从项目中取出模块(和组件)并将其放入npm包中,我就会收到该错误.
Please notice: If i take the code and put it into my project it works fine. But as soon as I take the module (and component) out of my project and put it into a npm package, i get that error.
Angular在2.3.1中使用, Angular CLI 1.0.0-beta.24, 打字稿2.0.10
Angular is used in 2.3.1, Angular CLI 1.0.0-beta.24, Typescript 2.0.10
推荐答案
最终解决方案:
必须使用Ahead-Of-Time编译器(ngc)编译库.它将添加一些元数据,以分配包含该库的项目来读取它.
You must compile your library using the Ahead-Of-Time compiler (ngc). It will add some metadata that allos the project that includes the library to read it.
请查看以下链接:
https://angular.io/docs/ts/latest/cookbook/aot-compiler.html https://medium. com/@cyrilletuzi/how-to-build-and-publish-angular-module-7ad19c0b4464#.9y88ipdk7
这篇关于**中的错误不是NgModule的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!