question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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" } }

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:9
  • Comments:31

github_iconTop GitHub Comments

49reactions
codingbadgercommented, Jun 7, 2018

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

9reactions
JuanEstebanKatzcommented, Apr 18, 2019

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);

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular 2 : No NgModule metadata found - Stack Overflow
After upgrading to Angular 6, I encountered the "ERROR in No NgModule metadata found for 'AppModule'." with the angular-bootstrap-md package, which requires ...
Read more >
Angular 6 upgrade: ERROR in No NgModule metadata found ...
This error is displayed when there's a template compilation error or a node_module library issue, but somehow the angular-cli process can't ...
Read more >
Angular – All Possible Solutions for 'No NgModule' - Stack 24/7
The error “No NgModule metadata found for 'AppModule'” could be caused by various reason: Moving Angular project folder. Upgrading ...
Read more >
ERROR in No NgModule metadata found for 'AppModule ...
I am getting [ng] ERROR while ionic serve in No NgModule metadata found for 'AppModule' this error. I searched a lot but not...
Read more >
Getting "No NgModule metadata found for 'class{}'." with ...
It seems that it is trying to find the bootstrapModule and platformBrowserDynamic functions within the entry module where the module class is defined....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found