"No NgModule metadata found for 'AppModule'" after Upgrade to Angular 5.1.0 and AngularCli 1.6.0
See original GitHub issueVersions
Angular CLI: 1.6.0
Node: 8.9.1
OS: win32 x64
Angular: 5.1.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/cdk: 5.0.0
@angular/cli: 1.6.0
@angular/flex-layout: 2.0.0-beta.10-4905443
@angular/material: 5.0.0
@ngtools/json-schema: 1.1.0
@schematics/schematics: 0.0.10
typescript: 2.5.0
webpack: 3.10.0
Repro steps
- Upgrade
@angularfrom5.0.2to5.1.0 - Upgrade
@angular/clifrom1.5.2to1.6.0 - Run
ng serve
Observed behavior
After doing the upgrade, the following error arises. I was able to resolve the issue as described here.
ERROR in Error: No NgModule metadata found for 'AppModule'.
at NgModuleResolver.resolve (C:\Users\volkende\WebstormProjects\project-name\node_modules\@angular\compiler\bundles\compiler.umd.js:20249:23)
at CompileMetadataResolver.getNgModuleMetadata (C:\Users\volkende\WebstormProjects\project-name\node_modules\@angular\compiler\bundles\compiler.umd.js:15218:60)
at visitLazyRoute (C:\Users\volkende\WebstormProjects\project-name\node_modules\@angular\compiler\bundles\compiler.umd.js:31063:104)
at AotCompiler.listLazyRoutes (C:\Users\volkende\WebstormProjects\project-name\node_modules\@angular\compiler\bundles\compiler.umd.js:31031:20)
at AngularCompilerProgram.listLazyRoutes (C:\Users\volkende\WebstormProjects\project-name\node_modules\@angular\compiler-cli\src\transformers\program.js:156:30)
at Function.NgTools_InternalApi_NG_2.listLazyRoutes (C:\Users\volkende\WebstormProjects\project-name\node_modules\@angular\compiler-cli\src\ngtools_api.js:44:36)
at AngularCompilerPlugin._getLazyRoutesFromNgtools (C:\Users\volkende\WebstormProjects\project-name\node_modules\@angular\cli\node_modules\@ngtools\webpack\src\angular_compiler_plug
in.js:247:66)
at Promise.resolve.then.then (C:\Users\volkende\WebstormProjects\project-name\node_modules\@angular\cli\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:561:50)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
Desired behavior
- Since no real changes have been made in
app.module.ts, as a developer I don’t want to have to take this step
Mention any other details that might be useful (optional)
- Before this issue occured, I had to explicitly
npm i --save-dev webpackto be able to runng serveat all (#7334)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:19
- Comments:81 (7 by maintainers)
Top 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 – 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 >No Ngmodule Metadata Found For 'Appmodule' After Upgrade ...
The error No NgModule metadata found for 'AppModule' could be caused by various reason: Moving Angular project folder. No NgModule metadata found for...
Read more >No NgModule metadata found for 'AppModule' ... when trying t
When trying to serve admin-pro from IntelliJ - or issue ng serve from command line respectively - I get the error message 'No...
Read more >no metadata for categoryrepository was found. nestjs - You.com
angular/angular-cli"No NgModule metadata found for 'AppModule'" after Upgrade to Angular 5.1.0 and AngularCli 1.6.0#8798. Created about 5 years ago.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I got the same error. The issue is fixed only when i manually re installed angular/cli. The webpack should come as a part of @angular/cli.
This should fix your issue. If this didn’t, clear the whole node_modules folder then
If @angular/cli install fails Retry
npm install --save-dev @angular/cli@latestagain.So I reverted what I did earlier today (actually a little git accident, but that’s another story) and updated again. Now I documented every step and took into account the previous answers.
npm i -g @angular/cli@latestrm -rf node_modules/rd /s /q node_modulespackage.json):npm cache clear --forcenpm cache verifynpm installnpm uninstall webpacknpm install --save-dev --save-exact @angular/cli@latest(from @JinsPeter 's answer)After all that
ng serveandng build [--prod]work fine.New findings:
What I do not understand:
webpack) and perform a clean reinstallHope that information helps