Search code examples
angularangular-ivy

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)

Solution

  • 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.