Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

2K
Views
Angular / Ivy error : Error: Token InjectionToken XXXXXXXXX is missing a ɵprov definition

Getting the error after updating to Angular 9 / Ivy compiler

ERROR Error: Token InjectionToken XXXXXXXXX is missing a ɵprov definition.
    at injectableDefOrInjectorDefFactory (vendor.js:47105)
    at providerToFactory (vendor.js:47210)
    at resolveProvider$1 (vendor.js:56430)
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

This can occur if you try to explicitly override an inherited injectable with undefined or null.

In Angular 8 this was ok

    {
        provide: AMBIENT_CART,
        useExisting: undefined
    }

With Angular 9 it needs to be changed to

    {
        provide: AMBIENT_CART,
        useValue: undefined
    }

If you're curious: In my case I was doing this for safety reasons, to make sure I didn't use this particular injectable by mistake.

over 4 years ago · Santiago Trujillo Report

0

I got the same error when running ng test after upgrading from Angular 8 --> 9: "Error: Token InjectionToken apiToken is missing a ɵprov definition."

My solution to this was very simple- there was a typo in the spec file that I guess didn't matter in Angular 8, but does in Angular 9? The last instance of 'useValue' below was incorrectly written 'usevalue'. Such an obscure error!

TestBed.configureTestingModule({ 
    imports: [ HttpClientTestingModule ], 
    providers: [ 
        { provide: ApiService, useValue: apiService }, 
        { provide: ProductsApiService, useValue: productsService }, 
        { provide: apiToken, useValue: mockApiToken } 
    ] 
});
over 4 years ago · Santiago Trujillo Report

0

I started receiving this error while running unit tests after upgrading an application from Angular 8 to Angular 10. The issue occurred because the existing spec file was using value instead of useValue in the providers array as shown in the below sample. Fixed the issue by changing it to useValue.

    beforeEach(async(() => {
    void TestBed.configureTestingModule({
        declarations: [
            MockPipe(TranslatePipe),
        ],
        imports: [
            HttpClientTestingModule,
        ],
        providers: [
            FormBuilder,
            MessageService,
            { provide: MESSAGES_TOKEN, value: {} }, //changed to useValue
        ]
    }).compileComponents();
}));
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!