I have this NgModule:
@NgModule({
imports: [
CommonModule
],
exports: [
SP21LoadingBar
],
declarations: [SP21LoadingBar]
})
export class SP21LoadingBarModule { }
The Cli ist telling me
ERROR in SP21LoadingBarModule is not an NgModule
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 is used in 2.3.1, Angular CLI 1.0.0-beta.24, Typescript 2.0.10
The bootstrap property or key of the NgModule decorator specifies which component should be loaded by Angular when the app-level module loads. Angular reads the bootstrap metadata and loads the app-level component, called AppComponent .
Every application has at least one Angular module, the root module, which must be present for bootstrapping the application on launch. By convention and by default, this NgModule is named AppModule .
Every Angular application has at least one NgModule class, the root module, which is conventionally named AppModule and resides in a file named app. module. ts . You launch your application by bootstrapping the root NgModule.
The FINAL solution:
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.
Please, have a look on the follow links:
https://angular.io/docs/ts/latest/cookbook/aot-compiler.html https://medium.com/@cyrilletuzi/how-to-build-and-publish-an-angular-module-7ad19c0b4464#.9y88ipdk7
You must use ngc
(@angular/compiler-cli) to compile your library, as opposed to using tsc
directly. Is this the case for you?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With