Angular-cli: "ERROR in No NgModule metadata found for 'AppModule'." when upgrading to Angular CLI 6.x

Created on 28 Apr 2018  Â·  31Comments  Â·  Source: angular/angular-cli

Versions

Angular CLI: 6.0.0-rc.7
Node: 9.4.0
OS: win32 x64
Angular: 5.2.8
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.5.10
@angular-devkit/build-angular     0.5.10
@angular-devkit/build-optimizer   0.4.9
@angular-devkit/core              0.5.10 (cli-only)
@angular-devkit/schematics        0.5.10 (cli-only)
@angular/cdk                      5.2.5
@angular/cli                      6.0.0-rc.7
@angular/material                 5.2.5
@angular/platform-server          5.2.10
@ngtools/json-schema              1.2.0
@ngtools/webpack                  6.0.0-rc.8
@schematics/angular               0.5.10 (cli-only)
@schematics/update                0.5.10
rxjs                              5.5.10
typescript                        2.8.3
webpack                           4.6.0

Repro steps

  • Installed 6.0.0-rc.5
  • Migrated project from 1.7.4 with RC5, command ng update @angular/cli --migrate-only -from=1 as suggested by the installer
  • Tried to run ng serve
  • Got error "ERROR in No NgModule metadata found for 'AppModule'."
  • Tried to upgrade to rc7
  • Serve still gives same error

Observed behavior

ng serve produces

Date: 2018-04-28T15:41:34.299Z
Hash: bfbd0778795913efc41e
Time: 10484ms
chunk {main} main.js, main.js.map (main) 1.95 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 694 bytes [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 5.4 kB [entry] [rendered]
chunk {scripts} scripts.js, scripts.js.map (scripts) 1.13 MB  [rendered]
chunk {styles} styles.js, styles.js.map (styles) 1.93 MB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 325 kB [initial] [rendered]

ERROR in No NgModule metadata found for 'AppModule'.
i ï½¢wdmï½£: Failed to compile.

Desired behavior

I expected the compiler to compile my project without errors as it did with 1.7.4

Mention any other details that might be useful (optional)

In this report my typescript version was unsupportedly high, but I get the same error after running:
npm install typescript@'>=2.4.2 <2.7.0'

angular.json:
{ "$schema": "./node_modules/@angular-devkit/core/src/workspace/workspace-schema.json", "version": 1, "newProjectRoot": "projects", "projects": { "Paperi 0": { "root": "", "projectType": "application", "architect": { "build": { "builder": "@angular-devkit/build-angular:browser", "options": { "outputPath": "dist", "index": "src/index.html", "main": "src/main.ts", "tsConfig": "src/tsconfig.app.json", "polyfills": "src/polyfills.ts", "assets": [ { "glob": "**/*", "input": "src/assets", "output": "/./assets" }, { "glob": "favicon.ico", "input": "src", "output": "/" } ], "styles": [ "src/styles.scss", "node_modules/bootstrap/dist/css/bootstrap.min.css", "node_modules/font-awesome/css/font-awesome.css", "node_modules/froala-editor/css/froala_editor.pkgd.min.css", "node_modules/lightbox2/dist/css/lightbox.min.css", "node_modules/ng2-dnd/bundles/ng2-dnd.umd.js" ], "scripts": [ "node_modules/jquery/dist/jquery.js", "node_modules/popper.js/dist/umd/popper.min.js", "node_modules/bootstrap/dist/js/bootstrap.js", "node_modules/froala-editor/js/froala_editor.pkgd.min.js", "node_modules/lightbox2/dist/js/lightbox.min.js", "node_modules/crypto-js/crypto-js.js" ] }, "configurations": { "production": { "optimization": true, "outputHashing": "all", "sourceMap": false, "extractCss": true, "namedChunks": false, "aot": true, "extractLicenses": true, "vendorChunk": false, "buildOptimizer": true, "fileReplacements": [ { "replace": "src/environments/environment.ts", "with": "src/environments/environment.prod.ts" } ] } } }, "serve": { "builder": "@angular-devkit/build-angular:dev-server", "options": { "browserTarget": "Paperi 0:build" }, "configurations": { "production": { "browserTarget": "Paperi 0:build:production" } } }, "extract-i18n": { "builder": "@angular-devkit/build-angular:extract-i18n", "options": { "browserTarget": "Paperi 0:build" } }, "test": { "builder": "@angular-devkit/build-angular:karma", "options": { "main": "src/test.ts", "karmaConfig": "./karma.conf.js", "polyfills": "src/polyfills.ts", "tsConfig": "src/tsconfig.spec.json", "scripts": [ "node_modules/jquery/dist/jquery.js", "node_modules/popper.js/dist/umd/popper.min.js", "node_modules/bootstrap/dist/js/bootstrap.js", "node_modules/froala-editor/js/froala_editor.pkgd.min.js", "node_modules/lightbox2/dist/js/lightbox.min.js", "node_modules/crypto-js/crypto-js.js" ], "styles": [ "src/styles.scss", "node_modules/bootstrap/dist/css/bootstrap.min.css", "node_modules/font-awesome/css/font-awesome.css", "node_modules/froala-editor/css/froala_editor.pkgd.min.css", "node_modules/lightbox2/dist/css/lightbox.min.css", "node_modules/ng2-dnd/bundles/ng2-dnd.umd.js" ], "assets": [ { "glob": "**/*", "input": "src/assets", "output": "/./assets" }, { "glob": "favicon.ico", "input": "src", "output": "/" } ] } }, "lint": { "builder": "@angular-devkit/build-angular:tslint", "options": { "tsConfig": [ "src/tsconfig.app.json", "src/tsconfig.spec.json" ], "exclude": [] } } } }, "Paperi 0-e2e": { "root": "", "projectType": "application", "cli": {}, "schematics": {}, "architect": { "e2e": { "builder": "@angular-devkit/build-angular:protractor", "options": { "protractorConfig": "./protractor.conf.js", "devServerTarget": "Paperi 0:serve" } }, "lint": { "builder": "@angular-devkit/build-angular:tslint", "options": { "tsConfig": [ "e2e/tsconfig.e2e.json" ], "exclude": [] } } } } }, "cli": {}, "schematics": { "@schematics/angular:component": { "prefix": "app", "styleext": "scss" }, "@schematics/angular:directive": { "prefix": "app" } } }

package.json:
{ "name": "nordic-sounds", "version": "0.0.0", "license": "MIT", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build --prod", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e", "build-newspaper-1": "ng build --prod --build-optimizer -aot --base-href /dev/sanomalehti-demo/", "serve-nordic-sounds": "ng serve --app nordic-sounds", "build-nordic-sounds": "ng build --prod --app nordic-sounds --output-path ./dist/nordic-sounds", "build-nordic-sounds-beta": "ng build --prod --app nordic-sounds --base-href /beta/ --output-path ./dist/nordic-sounds-beta", "serve-sanomalehti-demo": "ng serve --app sanomalehti-demo", "build-sanomalehti-demo": "ng build --prod --build-optimizer --app sanomalehti-demo --base-href /dev/sanomalehti-demo/ --output-path ./dist/sanomalehti-demo", "bundle-report-sanomalehti-demo": "webpack-bundle-analyzer dist/sanomalehti-demo/stats.json", "sourcemaps-sanomalehti-demo": "ng build --prod --sourcemaps --app sanomalehti-demo --base-href /dev/sanomalehti-demo/ --output-path ./dist/sanomalehti-demo" }, "private": true, "dependencies": { "@angular/animations": "5.2.8", "@angular/cdk": "^5.2.5", "@angular/common": "5.2.8", "@angular/compiler": "5.2.8", "@angular/core": "5.2.8", "@angular/forms": "5.2.8", "@angular/http": "5.2.8", "@angular/material": "^5.2.5", "@angular/platform-browser": "5.2.8", "@angular/platform-browser-dynamic": "5.2.8", "@angular/platform-server": "^5.2.10", "@angular/router": "5.2.8", "@ng-bootstrap/ng-bootstrap": "^1.1.2", "@types/crypto-js": "^3.1.39", "@types/smoothscroll-polyfill": "^0.3.0", "ajv": "^6.4.0", "angular-2-local-storage": "^1.0.1", "angular-froala-wysiwyg": "^2.8.1", "angular2-lightbox": "^1.3.0", "angular2-tooltips": "^1.0.10", "bootstrap": "^4.1.0", "classlist.js": "^1.1.20150312", "core-js": "^2.5.5", "crypto-js": "^3.1.9-1", "dom-to-image": "^2.6.0", "font-awesome": "^4.7.0", "lightbox2": "^2.9.0", "mammoth": "^1.4.5", "md-tooltip": "0.0.1-alpha.1", "ng2-component-spinner": "^0.2.1", "ng2-dnd": "^5.0.2", "ng2-file-upload": "^1.3.0", "ng2-scroll-to-el": "^1.2.1", "ngx-bootstrap": "^1.9.1", "ngx-contextmenu": "^4.2.0", "popper": "^1.0.0", "popper.js": "^1.14.3", "raf": "^3.4.0", "rxjs": "^5.5.10", "smoothscroll-polyfill": "^0.4.3", "tether": "^1.4.4", "web-animations-js": "^2.3.1", "zone.js": "^0.8.26" }, "devDependencies": { "@angular-devkit/build-angular": "~0.5.0", "@angular-devkit/build-optimizer": "^0.4.9", "@angular/cli": "^6.0.0-rc.7", "@angular/compiler-cli": "5.2.8", "@types/jasmine": "2.5.38", "@types/node": "^6.0.106", "codelyzer": "^4.3.0", "froala-editor": "^2.8.1", "jasmine-core": "~2.5.2", "jasmine-spec-reporter": "~3.2.0", "karma": "~1.4.1", "karma-chrome-launcher": "~2.0.0", "karma-cli": "~1.0.1", "karma-coverage-istanbul-reporter": "^0.2.0", "karma-jasmine": "~1.1.0", "karma-jasmine-html-reporter": "^0.2.2", "node-sass": "^4.9.0", "protractor": "^5.3.1", "raw-loader": "^0.5.1", "sass-loader": "^6.0.7", "source-map-explorer": "^1.5.0", "ts-node": "~2.0.0", "tslint": "^5.9.1", "typescript": "^2.8.3", "webpack-bundle-analyzer": "^2.11.1" } }

triage #1

Most helpful comment

A workaround for this is add the app.module.ts to the files array in your tsconfig.app.json

 "files": [
      "../src/app/app.module.ts"
       ]

You can then run ng build and ng serve without getting the error

All 31 comments

I'm still having this with the release version:

Angular CLI: 6.0.0
Node: 9.4.0
OS: win32 x64
Angular: 6.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.0
@angular-devkit/build-angular     0.6.0
@angular-devkit/build-optimizer   0.4.9
@angular-devkit/core              0.6.0
@angular-devkit/schematics        0.6.0 (cli-only)
@angular/cdk                      5.2.5
@angular/material                 6.0.1
@angular/platform-server          5.2.10
@ngtools/webpack                  6.0.0
@schematics/angular               0.6.0 (cli-only)
@schematics/update                0.6.0
rxjs                              6.1.0
typescript                        2.7.2
webpack                           4.6.0

I can't compile, it always ends up with:

Date: 2018-05-08T14:11:12.824Z
Hash: 02cf6c33a9793e065921
Time: 11557ms
chunk {main} main.js, main.js.map (main) 1.95 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 694 bytes [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 5.4 kB [entry] [rendered]
chunk {scripts} scripts.js, scripts.js.map (scripts) 1.13 MB [rendered]
chunk {styles} styles.js, styles.js.map (styles) 2.61 MB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 325 kB [initial] [rendered]

ERROR in No NgModule metadata found for 'AppModule'.

Please let me know if there are any details I can provide. This project compiles and builds without errors on Angular CLI 1.7.x

Here's the app.module if it helps:

import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { RouterModule, PreloadAllModules, NoPreloading } from '@angular/router';
import { RouteReuseStrategy } from '@angular/router';
import { CustomReuseStrategy } from './route-reuse-strategy';
import { AppComponent } from './app.component';

import { SearchResultsListComponent } from './search-results-list/search-results-list.component';
import { ItemPreviewVideoComponent } from './item-preview-video/item-preview-video.component';
import { ItemPreviewTextComponent } from './item-preview-text/item-preview-text.component';
import { ItemPreviewTitleComponent } from './item-preview-title/item-preview-title.component';
import { ItemDetailViewInlineLayout2Component } from './item-detail-view-inline-layout-2/item-detail-view-inline-layout-2.component';

import { ItemChildDetailViewInlineComponent } from './item-child-detail-view-inline/item-child-detail-view-inline.component';
import { ReaderPageLayout2Component } from './reader-page-layout-2/reader-page-layout-2.component';
import { ItemPreviewAudioComponent } from './item-preview-audio/item-preview-audio.component';
import { ItemPreviewNoneComponent } from './item-preview-none/item-preview-none.component';
import { ItemPreviewImageComponent } from './item-preview-image/item-preview-image.component';
import { ItemPreviewComponent } from './item-preview/item-preview.component';

// Pages
import { SearchPageComponent } from './search-page/search-page.component';
import { CartPageComponent } from './cart-page/cart-page.component';
import { StartPageComponent } from './start-page/start-page.component';

import { DataService } from './data-service/data.service';


import { SearchResultItemComponent } from './search-result-item/search-result-item.component';

import { LocalStorageModule } from 'angular-2-local-storage';

import { RouterOutletExtensionDirective } from './router-outlet-extension.directive';

import { ScrollToModule } from 'ng2-scroll-to-el';

import { SharedServicesModule } from './shared-services/shared-services.module';

import { InitializeService } from './initialize-service/initialize.service';
import { PreloadSelectedModulesList } from './custom-preload-strategy';
import { PageNotFoundComponent } from './page-not-found/page-not-found.component';
import { SiteComponent } from './site/site.component';
import { PageTemplateComponent } from './page-template/page-template.component';

@NgModule({
  declarations: [
    AppComponent,
    SearchPageComponent,
    CartPageComponent,
    SearchResultsListComponent,
    ItemPreviewVideoComponent,
    ItemPreviewTextComponent,
    ItemPreviewTitleComponent,
    ItemDetailViewInlineLayout2Component,
    ItemChildDetailViewInlineComponent,
    ReaderPageLayout2Component,
    ItemPreviewAudioComponent,
    ItemPreviewNoneComponent,
    ItemPreviewImageComponent,
    ItemPreviewComponent,
    SearchResultItemComponent,

    StartPageComponent,
    RouterOutletExtensionDirective,

    SiteComponent
   ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    BrowserAnimationsModule,
    SharedServicesModule.forRoot(),
    ScrollToModule.forRoot(),
    LocalStorageModule.withConfig({
      prefix: 'app-root',
      storageType: 'localStorage'
    }),
    RouterModule.forRoot([
      {
        path: ':siteId',
        component: SiteComponent,
        canActivate: [InitializeService],

        /* Doesn't let the user leave the root until site settings have been loaded */
        children: [
          {
            path: '',
            pathMatch: 'full',
            redirectTo: 'start'
          },
          {
            path: 'start',
            component: StartPageComponent
            // canActivate: [InitializeService]
          },
          {
            path: 'search',
            component: SearchPageComponent,
            /* Doesn't let the user leave the root until site settings have been loaded */
            // canActivate: [InitializeService]
          },
          {
            path: 'search/:searchWords',
            component: SearchPageComponent,
            /* Doesn't let the user leave the root until site settings have been loaded */
            // canActivate: [InitializeService]
          },
          {
            path: 'search/details/:id',
            component: ReaderPageLayout2Component,

            /* Doesn't let the user leave the root until site settings have been loaded */
            // canActivate: [InitializeService]
          },
          {
            path: 'page/:id',
            component: PageTemplateComponent,

            /* Doesn't let the user leave the root until site settings have been loaded */
            // canActivate: [InitializeService]
          },
          {
            path: 'login',
            data: { preload: false },
            loadChildren: "app/login/login.module#LoginModule",

            /* Doesn't let the user leave the root until site settings have been loaded */
            // canActivate: [InitializeService]
          },
          {
            path: 'admin',
            data: { preload: false },
            loadChildren: "app/admin/admin.module#AdminModule"
          },    
          {
            path: 'cart',
            component: CartPageComponent,

            /* Doesn't let the user leave the root until site settings have been loaded */
            // canActivate: [InitializeService]
          },
        ]
      },
      {
        /** TODO: Lisää tähän NO ID -sivu **/
        path: '**',
        component: PageNotFoundComponent,
        // pathMatch: 'full',
        // redirectTo: '1/start'
      }
    ],
    {
        preloadingStrategy: PreloadSelectedModulesList,
        useHash: true
    })
  ],
  providers: [
    DataService,
    PreloadSelectedModulesList,
    { provide: RouteReuseStrategy, useClass: CustomReuseStrategy }
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

I am getting the exact same output / error, also after making the same upgrade.

Date: 2018-05-13T21:37:06.739Z
Hash: 24441611d6ea08acfcc9
Time: 4451ms
chunk {main} main.js, main.js.map (main) 2.18 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 701 bytes [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 5.4 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 19.9 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 326 kB [initial] [rendered]

ERROR in No NgModule metadata found for 'AppModule'.

same problem here
$ ng serve
* Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ *
14% building modules 36/38 modules 2 active …tstrap-mdscssbootstrapbootstrap.scssWARNING: The text-hide() mixin has been deprecated as of v4.1.0. It will be removed entirely in v5.
on line 10 of node_modules/angular-bootstrap-md/scss/bootstrap/mixins/_text-hide.scss, in mixin text-hide
from line 57 of node_modules/angular-bootstrap-md/scss/bootstrap/utilities/_text.scss
from line 14 of node_modules/angular-bootstrap-md/scss/bootstrap/_utilities.scss
from line 41 of stdin

Date: 2018-05-17T19:08:34.370Z
Hash: 17a1f9847cfc9cf4d597
Time: 4154ms
chunk {main} main.js, main.js.map (main) 1.99 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 710 bytes [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 5.22 kB [entry] [rendered]
chunk {scripts} scripts.js, scripts.js.map (scripts) 381 kB [rendered]
chunk {styles} styles.js, styles.js.map (styles) 476 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 325 kB [initial] [rendered]

ERROR in No NgModule metadata found for 'AppModule'.
i ï½¢wdmï½£: Failed to compile.

same problem

Date: 2018-05-20T10:31:26.948Z
Hash: 17a1f9847cfc9cf4d597
Time: 5178ms
chunk {main} main.js, main.js.map (main) 1.94 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 687 bytes [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 5.22 kB [entry] [rendered]
chunk {scripts} scripts.js, scripts.js.map (scripts) 381 kB [rendered]
chunk {styles} styles.js, styles.js.map (styles) 475 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 325 kB [initial] [rendered]

ERROR in No NgModule metadata found for 'AppModule'.
i ï½¢wdmï½£: Failed to compile.

I started having the same error after upgrading to Angular 6. It happens when I build production. The issue on my side seems to be related to enabling aot and buildOptimizer. When these are enabled, I get the issue. When I disable these two, the problem disappear. Here is my configuration:

"prod": {
  "optimization": true,
  "outputHashing": "all",
  "sourceMap": false,
  "extractCss": true,
  "namedChunks": false,
  "aot": true,
  "extractLicenses": true,
  "vendorChunk": false,
  "buildOptimizer": true,
  "fileReplacements": [
    {
      "replace": "src/environments/environment.ts",
      "with": "src/environments/environment.prod.ts"
    }
  ]
}

Also started having the issue after upgrading to Angular 6, although it only occurs when aot is set to false (contrary to @rafidka's config).
Configuration that causes the error:

"qa": {
  "optimization": false,
  "outputHashing": "all",
  "sourceMap": false,
  "extractCss": false,
  "namedChunks": false,
  "aot": false,
  "extractLicenses": true,
  "vendorChunk": false,
  "buildOptimizer": false,
  "fileReplacements": [
    {
      "replace": "src/environments/environment.ts",
      "with": "src/environments/environment.qa.ts"
    }
  ]
}

We, too, are experiencing this issue, but only when AoT is disabled, e.g., ng build produces the error, but ng build --aot works fine. Is there anything we can do to help debugging it? ng build --verbose just prints the same error twice.

As an update, for us it appears that all users who experience this issue when building without AoT are Windows users. Linux and macOS users aren't seeing this.

I too am seeing this issue after upgrading from v5.2 to v6

Angular CLI: 6.0.8
Node: 8.11.2
OS: win32 x64
Angular: 6.0.4
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Running ng build or ng serve produces the error ERROR in No NgModule metadata found for 'AppModule'.

However running ng build --aot or ng serve --aot does not.

A workaround for this is add the app.module.ts to the files array in your tsconfig.app.json

 "files": [
      "../src/app/app.module.ts"
       ]

You can then run ng build and ng serve without getting the error

@codingbadger thank you so much for this workaround! Hopefully it gets fixed really soon.

I can also confirm that the workaround suggested by @codingbadger works for our Windows users.

Another confirmation that the workaround suggested by @codingbadger works on windows

thank you @codingbadger , spent hours on this issue and was about to abandon our upgrade to angular 6.

Hope they fix this soon

@Airblader @richardscholten73 which version of Windows are you on? I'm on 8.1 but the workaround doesn't seem to work

@maartentibau windows 10

@Airblader @richardscholten73 I can confirm that upgrading my nodejs version to 9.x and removing my node_modules folder, the lock file and doing a clean npm i did solve the problem. I'm on Windows 8.1

I'm on the latest Angular CLI version, TS 2.8.4

I'm having this issue when i try to run a e2e test in travis.. if I run this local works as expected..

https://travis-ci.org/mariohmol/ng-brazil/builds/431752859

Maybe the problem i'm passing in this build might help to reproduce this error?

I'm having this issue on a Angular 6 to Angular 7 upgrade.

UPDATE: After upgrading to Node 10 from 9, and implementing the install using the old npm install method, instead of ngUpdate, I got a successful build.

Thanks for the solution of adding it app.module.ts in tsconfig.app.json. It worked for me as well.

Hey Guys, I just added this line "baseUrl": "../node_modules", on the tsconfig.app.json file under compilerOptions.... It worked fine for me with that....

"compilerOptions": {
    "outDir": "../out-tsc/app",
    "baseUrl": "../node_modules",
    "types": []
  } ... 

You can see it here: https://github.com/angular/angular-cli/issues/10837

Hi!

I dont think this changes makes sense but i tested anyway.. and didnt work =(

Here is the change:
https://github.com/mariohmol/ng-brazil/compare/4c9a7d272f29...20955ef76f98

Here is the build error:
https://travis-ci.org/mariohmol/ng-brazil/builds/448330078

I upgrade to Angular7 and got the same error. Have tried all suggestions above but nothing worked in my case :(

````
ng build --project=admin --no-progress

Date: 2018-10-31T09:01:37.961Z
Hash: c852709f74070d0f5f6c
Time: 40952ms
chunk {main} main.js, main.js.map (main) 643 bytes [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 105 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.22 kB [entry] [rendered]
chunk {scripts} scripts.js, scripts.js.map (scripts) 232 kB [rendered]
chunk {styles} styles.js, styles.js.map (styles) 1.62 MB [initial] [rendered]

ERROR in No NgModule metadata found for 'AppModule'.
```

I too have upgraded to Angular 7 and my setup has changed slightly from my fix mentioned above.

Angular CLI: 7.0.3
Node: 10.12.0
OS: win32 x64

Running @angular/[email protected]

I no longer require a reference to app.module.ts in my tsconfig.app.json file. It now looks like this:

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "module": "es2015",
    "types": ["node"]
  },
  "exclude": [
    "src/test.ts",
    "**/*.spec.ts"
  ]
}

I was working on a project, and it required me to add @types/jquery in include of tsconfig.json.
Now i am getting this error

Date: 2018-10-31T09:01:37.961Z
Hash: c852709f74070d0f5f6c
Time: 40952ms
chunk {main} main.js, main.js.map (main) 643 bytes [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 105 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.22 kB [entry] [rendered]
chunk {scripts} scripts.js, scripts.js.map (scripts) 232 kB  [rendered]
chunk {styles} styles.js, styles.js.map (styles) 1.62 MB [initial] [rendered]

ERROR in No NgModule metadata found for 'AppModule'.

Let me know if there is any workaround

I solve the issue, in the file main.ts, I remove this part .catch(err => console.error(err)); and the final line is just: platformBrowserDynamic().bootstrapModule(AppModule);

We are in a Hybrid app with angular-ts-decorator and angular-cli. As @rafidka said. It works when setting aot: false. Any permanent solution to this?

Fixed it!
I had to add entryModule in tsconfig.app.json file.

"angularCompilerOptions": {
    "entryModule": "./app/app.module#AppModule"
  }

No Need to set aot: false.

I am getting same help me here.

[ng] chunk {es2015-polyfills} es2015-polyfills.js, es2015-polyfills.js.map (es2015-polyfills) 285 kB [initial] [rendered]
[ng] chunk {main} main.js, main.js.map (main) 1.9 kB [initial] [rendered]
[ng] chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 93.2 kB [initial] [rendered]
[ng] chunk {runtime} runtime.js, runtime.js.map (runtime) 6.08 kB [entry] [rendered]
[ng] chunk {styles} styles.js, styles.js.map (styles) 65.8 kB [initial] [rendered]
[ng] chunk {vendor} vendor.js, vendor.js.map (vendor) 327 kB [initial] [rendered]
[ng]
[ng] ERROR in No NgModule metadata found for 'AppModule'.

Ionic:

ionic (Ionic CLI) : 4.10.3 (C:UsersadminAppDataRoamingnpmnode_modulesionic)
Ionic Framework : @ionic/angular 4.11.2
@angular-devkit/build-angular : 0.13.9
@angular-devkit/schematics : 7.3.9
@angular/cli : 7.3.9
@ionic/angular-toolkit : 1.5.1

Cordova:

cordova (Cordova CLI) : 9.0.0 ([email protected])
Cordova Platforms : android
Cordova Plugins : no whitelisted plugins (0 plugins total)

System:

Android SDK Tools : 26.1.1 (C:UsersadminAppDataLocalAndroidSdk)
NodeJS : v10.15.1 (C:Program Filesnodejsnode.exe)
npm : 6.4.1
OS : Windows 10

Just upgraded from 9.0.6 to 9.1.0 and still seeing the same issue.

The only thing that works for me is saving again the app.module.ts file while it is watching.
Need a more permanent solution.

Thanks for reporting this issue. However, you didn't provide sufficient information for us to understand and reproduce the problem. Please check out our submission guidelines to understand why we can't act on issues that are lacking important information.

If the problem persists, please file a new issue and ensure you provide all of the required information when filling out the issue template.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings