我有这个 NgModule:
@NgModule({
imports: [
CommonModule
],
exports: [
SP21LoadingBar
],
declarations: [SP21LoadingBar]
})
export class SP21LoadingBarModule { }
客户告诉我
ERROR in SP21LoadingBarModule is not an NgModule
请注意:如果我获取代码并将其放入我的项目中,它就可以正常工作。但是,一旦我将模块(和组件)从我的项目中取出并将其放入 npm 包中,我就会收到该错误。
2.3.1中使用了Angular,
Angular CLI 1.0.0-beta.24,
打字稿 2.0.10
最终的解决方案:
您必须使用提前编译器 (ngc) 编译您的库。它将添加一些元数据,允许包含该库的项目读取它。
请查看以下链接:
https://angular.io/docs/ts/latest/cookbook/aot-compiler.html https://angular.io/docs/ts/latest/cookbook/aot-compiler.html
https://medium.com/@cyrilletuzi/how-to-build-and-publish-an-angular-module-7ad19c0b4464#.9y88ipdk7 https://medium.com/@cyrilletuzi/how-to-build-and-publish-an-angular-module-7ad19c0b4464#.9y88ipdk7
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)