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:

SSL Error - The connection for this site is not secure

 After cloning a git repo of dot net framework website and trying to run it all I could see was this error Turns out the fix was to simply e...