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.

No NgModule metadata found for {module_name}

See original GitHub issue

I’m submitting a…


[ ] Regression (a behavior that used to work and stopped working in a new release)
[X] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

I’ve got two modules: one main module which tries to set up some routing, and one mature, big module, that will be the first of many to be added to this application.

Expected behavior

The main module should lazy-load the entire secondary module with no problem. Needless to say, that module works perfectly when run standalone.

Minimal reproduction of the problem with instructions

I’ve got one main module which only has it’s default root component. Inside the src folder, I created a folder “modules” in which I relocated the old module. The main module looks like this:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { routing } from './routing';


@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    routing
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

That “routing” import looks like the following:

import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AppComponent} from './app.component';

const routes: Routes = [
  { path: '', redirectTo: 'init', pathMatch: 'full' },
  { path: 'init', component: AppComponent },
  { path: 'achieved_combined', loadChildren: '../modules/MBO_plan_achieved/src/app/app.module#AchievedCombined_Module' }
];

export const routing: ModuleWithProviders = RouterModule.forRoot(routes);

If you wonder, I’ve got also the other module with this -apparently, needed- routing file:

import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

import { AppComponent } from './app.component';

const routes: Routes = [
  { path: '', component: AppComponent }
];

export const routing: ModuleWithProviders = RouterModule.forChild(routes);
@NgModule({
  declarations: [
    AppComponent,
    SegmentsComponent,
    GranularityComponent,
    ChartPickerComponent,
    DatePickerWrapperComponent, 
    ChartWrapperComponent,
    DynamicTable,
    TableFormat,
    SelectedLevelsComponent
  ],
  imports: [
    BrowserModule,
    AngularFontAwesomeModule,
    FormsModule, 
    NgbModule.forRoot(),
    Ng4LoadingSpinnerModule.forRoot(),
    HttpModule,
    MyDateRangePickerModule,
    ChartModule,
    routing
  ],
  providers: [RefresherService, DataRequester],
  bootstrap: [AppComponent]
})
export class AchievedCombined_Module { }

What is the motivation / use case for changing the behavior?

We’re developing a big application in parts. The first part is ready and working! But now, I’ve got to make this main module in order to serve it, and add the future modules one by one to it.

Environment


Angular CLI: 1.5.4
Node: 8.9.1
OS: win32 x64
Angular: 5.2.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.5.4
@angular-devkit/build-optimizer: 0.0.38
@angular-devkit/core: 0.0.25
@angular-devkit/schematics: 0.0.48
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.4
@schematics/angular: 0.1.13
@schematics/schematics: 0.0.13
typescript: 2.4.2
webpack: 3.8.1

Any help regarding this? I really don’t know what to do to fix this weird bug:

ERROR in Error: No NgModule metadata found for 'AchievedCombined_Module'.
    at NgModuleResolver.resolve (C:\Dev\Projects\AngularFrontend\MainModule\node_modules\@angular\compiler\bundles\compiler.umd.js:20277:23)
    at CompileMetadataResolver.getNgModuleMetadata (C:\Dev\Projects\AngularFrontend\MainModule\node_modules\@angular\compiler\bundles\compiler.umd.js:15230:60)
    at visitLazyRoute (C:\Dev\Projects\AngularFrontend\MainModule\node_modules\@angular\compiler\bundles\compiler.umd.js:31167:104)
    at visitLazyRoute (C:\Dev\Projects\AngularFrontend\MainModule\node_modules\@angular\compiler\bundles\compiler.umd.js:31171:17)
    at AotCompiler.listLazyRoutes (C:\Dev\Projects\AngularFrontend\MainModule\node_modules\@angular\compiler\bundles\compiler.umd.js:31135:20)
    at AngularCompilerProgram.listLazyRoutes (C:\Dev\Projects\AngularFrontend\MainModule\node_modules\@angular\compiler-cli\src\transformers\program.js:156:30)
    at Function.NgTools_InternalApi_NG_2.listLazyRoutes (C:\Dev\Projects\AngularFrontend\MainModule\node_modules\@angular\compiler-cli\src\ngtools_api.js:44:36)
    at AngularCompilerPlugin._getLazyRoutesFromNgtools (C:\Dev\Projects\AngularFrontend\MainModule\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:247:66)
    at Promise.resolve.then.then (C:\Dev\Projects\AngularFrontend\MainModule\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:538:50)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

webpack: Failed to compile.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
Zerokkcommented, Jan 16, 2018

@alexzuza No, sorry, but if you have any doubts on my project setup just ask me, anyways I think it’s pretty well explained.

0reactions
angular-automatic-lock-bot[bot]commented, Sep 13, 2019

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.

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 >
ERROR in No NgModule metadata found for 'AppModule'
You hit npm start and you get the following error: ERROR in No NgModule metadata found for 'AppModule'. You save any file again...
Read more >
ERROR in No NgModule metadata found for '{Module Name}'
Coding example for the question ERROR in No NgModule metadata found for '{Module Name}'-angular.js.
Read more >
Angular – ERROR in No NgModule metadata found for '{Module ...
Angular – ERROR in No NgModule metadata found for '{Module Name}'. angularwebpack. I am using the following Version of CLI:
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.
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