3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ionic4で@ionic-native/cameraが使えないときの対処法

Posted at

エラーの内容

以下を実行してもcameraモジュールが使えない(2019/1/30日現在)

console
$ ionic cordova plugin add cordova-plugin-camera
$ npm install @ionic-native/camera
app.modules.ts
import { Camera } from '@ionic-native/camera';

providers: [
    StatusBar,
    SplashScreen,
    {provide: ErrorHandler, useClass: IonicErrorHandler},
    Camera
]

エラーメッセージ
Type 'CameraOriginal' is missing the following properties from type 'FactoryProvider'

原因

@ionic-native/coreのバージョンが5.0.0より低い

対処法

@ionic-native/coreのバージョンを上げる
「@」以降のバージョン指定は適宜書き直してください。

console
npm i --save @ionic-native/core@5.0.0
npm i --save @ionic-native/splash-screen@5.0.0
npm i --save @ionic-native/status-bar@5.0.0
ionic cordova plugin add cordova-plugin-camera
npm install @ionic-native/camera
app.modules.ts
import { StatusBar } from '@ionic-native/status-bar/ngx';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { Camera } from '@ionic-native/camera/ngx';

providers: [
    StatusBar,
    SplashScreen,
    Camera,
    {provide: ErrorHandler, useClass: IonicErrorHandler}
]

import元のディレクトリが「@ionic-native/camera」から「@ionic-native/camera/ngx」になっていることに注意してください。

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?