Tuesday, January 15, 2019

Angular: ERROR in No NgModule metadata found for 'AppModule'

When trying to run an angular app I was getting the error:

ERROR in No NgModule metadata found for 'AppModule'.

The error could possibly be becuase of following reasons:

  1. There is a statement of the form 
    platformBrowserDynamic().bootstrapModule(App)
    in main.ts file where App is not really a module. Solution is to reaplace App with AppModule
  2. The patformBrowserDynamic variable is declared as a constant 
    const platform = platformBrowserDynamic();
    platform.bootstrapModule(App);
    Solution is remove const keyword
  3. And sometimes if the compiler fails for any unknown reason, try editing app.module.ts file (like deleting and reinserting a character). After saving the file the app is automatically recompiled and starts working normally if it has already been started using ng serve or npm start.
Stackoverflow reference:

No comments:

c# httpclient The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch

 If we get this error while trying to get http reponse using HttpClient object, it could mean that certificate validation fails for the remo...