I\'m getting this error after migrating to NgModule, the error doesn\'t help too much, any advice please?
Error: Error: Unexpected value \'undefined\' import
I had the same problem. In my case, the reason is an extra comma.
I met this problem at the situation:
- app-module
--- app-routing // app router
----- imports: [RouterModule.forRoot(routes)]
--- demo-module // sub-module
----- demo-routing
------- imports: [RouterModule.forRoot(routes)] // --> should be RouterModule.forChild!
because there is only a root
.
This can be caused by multiple scenarios like
imports: [
BrowserModule
,routing <= Missing Comma
,FeatureComponentsModule
],
imports: [
BrowserModule,
,routing <=Double Comma
,FeatureComponentsModule
],
Another reason could be some code like this:
import { NgModule } from '@angular/core';
import { SharedModule } from 'app/shared/shared.module';
import { CoreModule } from 'app/core/core.module';
import { RouterModule } from '@angular/router';
import { COMPANY_ROUTES } from 'app/company/company.routing';
import { CompanyService } from 'app/company/services/company.service';
import { CompanyListComponent } from 'app/company/components/company-list/company-list.component';
@NgModule({
imports: [
CoreModule,
SharedModule,
RouterModule.forChild(COMPANY_ROUTES)
],
declarations: [
CompanyListComponent
],
providers: [
CompanyService
],
exports: [
]
})
export class CompanyModule { }
Because exports is empty array and it has , before it, it should be removed.
I was facing the same problem. Issue was that I was importing some class from index.ts
import {className} from '..shared/index'
index.ts contain the export statement
export * from './models';
I changed it to the .ts file which contain the actual class object
import {className} from '..shared/model'
and it resolved.
This issue of circular dependencies of two module
Module 1:import Module 2
Module 2:import Module 1