** 中的错误不是 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 中使用,角 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.htmlhttps://medium.com/@cyrilletuzi/how-to-build-and-publish-an-angular-module-7ad19c0b4464#.9y88ipdk7
这篇关于** 中的错误不是 NgModule的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!