Skip to content

Value at position 6 in the NgModule.imports of AppModule is not a reference #36673

@baljinder-inmarsat

Description

@baljinder-inmarsat

🐞 bug report

Affected Package

"@angular/core": "^9.1.2",

Is this a regression?

Yes fine in Angular 8.2.14

Description

I am trying to upgrade, However I am stuck due to the following error in my terminal:
Screenshot from 2020-04-16 18-45-32

I've been following all the steps, using https://update.angular.io/#8.0:9.0. but for some reason I cannot resolve this issue.

I had looked at this issue and worked out where the problem, line, is in my app.module.ts.
ApiModule.forRoot()
if I remove forRoot(), the error has gone but I need the forRoot().

Thanks

api.module.ts:


@NgModule({
  declarations: [],
  imports: []
})
export class ApiModule {
  // We need to use forRoot to match with the dev API module.
  public static forRoot(): ModuleWithProviders< ApiModule > {
    return {
      ngModule: ApiModule,
      providers: [
        {
          provide: JWT_OPTIONS,
          useValue: {}
        },
        JwtHelperService,
        GxAssuranceApiService,
        CustomersApiService,
        FoldersApiService,
        OrdersApiService,
        ProductsApiService,
        SitesApiService,
        SystemStatusApiService,
        UsersApiService,
        RefDataApiService
      ]
    };
  }
}

🔥 Exception or Error


ERROR in src/app/app.module.ts:79:12 - error NG1010: Value at position 6 in the NgModule.imports of AppModule is not a reference: [object Object]

 79   imports: [
               ~
 80     /**
    ~~~~~~~
... 
166     })
    ~~~~~~
167   ],
    ~~~


🌍 Your Environment

Angular Version:


Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.901.1
@angular-devkit/build-angular     0.901.1
@angular-devkit/build-optimizer   0.901.1
@angular-devkit/build-webpack     0.901.1
@angular-devkit/core              9.1.1
@angular-devkit/schematics        9.1.1
@angular/cdk                      9.2.1
@angular/cli                      9.1.1
@ngtools/webpack                  9.1.1
@nguniversal/common               9.1.0
@nguniversal/express-engine       9.1.0
@schematics/angular               9.1.1
@schematics/update                0.901.1
rxjs                              6.5.5
typescript                        3.8.3
webpack                           4.42.0

Anything else relevant?
#36271
This helped in identifying that the error is to do with the forRoot() but I cannot find a solution in my case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: compilerIssues related to `ngc`, Angular's template compiler

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions