1

I can't get the HttpClientModule, the following error appears while loading this ModuleType. I get this error in the registerNgModuleType method from Angular.

function registerNgModuleType(ngModuleType) {
    if (ngModuleType.ɵmod.id !== null) {
        /** @type {?} */
        const id = ngModuleType.ɵmod.id;
        /** @type {?} */
        const existing = (/** @type {?} */ (modules.get(id)));
        assertSameOrNotExisting(id, existing, ngModuleType);
        modules.set(id, ngModuleType);
    }

"Cannot read property 'id' of undefined".

This my app.module.ts file app.module.ts:

import { NgModule } from '@angular/core';

import { BrowserModule } from '@angular/platform-browser';
import { MatMenuModule } from '@angular/material/menu';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import {MatIconModule} from '@angular/material/icon';
import {MatButtonModule} from '@angular/material/button';
import { ReactiveFormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';

import { AppComponent } from './app.component';
import { StartComponent } from './start/start.component';
import { HeaderComponent } from './header/header.component';
import { SelectLanguageComponent } from './select-language/select-language.component';
import { PersonComponent } from './person/person.component';
import { DynamicFormQuestionComponent } from './question/question.component';
import { DynamicFormComponent } from './dynamic-form/dynamic-form.component';
import { AppRoutingModule } from './app-routing.module';


@NgModule({
  declarations: [
    AppComponent,
    StartComponent,
    HeaderComponent,
    SelectLanguageComponent,
    PersonComponent,
    DynamicFormQuestionComponent,
    DynamicFormComponent
  ],
  imports: [
    BrowserModule,
    HttpClientModule,
    MatMenuModule,
    BrowserAnimationsModule,
    MatIconModule,
    MatButtonModule, 
    ReactiveFormsModule,  
    AppRoutingModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
4
  • 3
    Thie error is not related with httpClientModule I gues.. Can you share your code and mention in which line exactly you get the error?? Commented Mar 7, 2020 at 13:35
  • Can you please add the screenshot of error that you are getting in console ?? Commented Mar 7, 2020 at 13:45
  • Why do you think this error has something to do with the HttpClientModule? It seems to me that ngModulType.emod is not defined and that's the issue. Commented Mar 7, 2020 at 13:58
  • yes, it is not defined when the HttpClientModule is loading.. Commented Mar 7, 2020 at 14:59

1 Answer 1

1

The problem was that there was a dependency missing for that package!

Sign up to request clarification or add additional context in comments.

3 Comments

Hello, how did you solve it? What dependencies were you missing?
I just deleted the folder with the node_modules in the project file and then restarted my Visual Studio Code and just run 'npm install' and the problem was gone.
Thanks! I've solved it now. I took out the flashmessages and everything worked well from there. I

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.