Type 'CameraOriginal' is not assignable to type 'Provider'

I’ve upgraded my ionic 3 to ionic 5 and multiple ionic-native imports stopped working with the following error:

ERROR in src/app/app.module.ts:203:5 - error TS2322: Type 'CameraOriginal' is not assignable to type 'Provider'.
  Type 'CameraOriginal' is missing the following properties from type 'TypeProvider': apply, call, bind, prototype, and 5 more.

Found this comment that I need to add /ngx at the end of the import but this didn’t help, the error stays the same.

my new import is:

import { Camera } from '@ionic-native/camera/ngx';

Is that correct for the upgrade?
What else could be wrong here because this solution doesn’t help.

This is true, but:

  • You must scour every single place you’re importing and ensure the trailing /ngx is present
  • You must make sure all @ionic-native pieces are at least major version 5
  • As long as you’re making sweeping changes, I’d recommend switching to Capacitor’s Camera instead of the cordova one
1 Like

You must scour every single place you’re importing and ensure the trailing /ngx is present

It works, thanks! You were right, apart from the mobule where the error was raised, there are were other places that were importing the Camera without /ngx. After updating all imports (on all pages) the error has gone.

You must make sure all @ionic-native pieces are at least major version 5

I have updated all @ionic-native packages to the latest available which is 5.28.0

As long as you’re making sweeping changes, I’d recommend switching to Capacitor’s Camera instead of the cordova one

I will look into it, thanks for the suggestion, is there a list of similar suggestions when upgrading to the latest ionic (the upgrade guide is missing this Camera replacement)?

Also, I have around 20 other @ionic-native packages, should it be done for all of them? Was it some breaking change of the @ionic-native package update?

I would say that if you can find something in the Capacitor ecosystem to replace whatever you’re using Cordova for now, try doing so.

Yes, you must.

It’s why the major version 4 → 5 change happened. The rationale, IIRC, was that it was necessary in order to allow expanding Ionic Native to work with non-Angular frameworks, such as React and Vue. The architecture before major version 5 was inextricably Angular-dependent.

1 Like