Ionic 2 native file api : cordova is not defined

Hello everyone,

I want to use the cordova “File” plugin but I get the error “cordova is not defined” when running in the browser and simulator.

As shown in the doc :

I have proceed as follow :

import { Component } from '@angular/core';
import { ionicBootstrap, Platform } from 'ionic-angular';
import { StatusBar } from 'ionic-native';
import { File } from 'ionic-native';
import { HomePage } from './pages/home/home';

declare var cordova: any;

  template: '<ion-nav [root]="rootPage"></ion-nav>'
export class MyApp {
  rootPage: any = HomePage;

  constructor(public platform: Platform) {
    platform.ready().then(() => {

      var fs:string = cordova.file.dataDirectory;
      File.checkDir(fs, 'mydir').then(_ => console.log('yay')).catch(err => console.log('boooh'));



Any ideas ?

Environment :

Cordova CLI: 6.3.1
Gulp version: CLI version 3.9.1
Gulp local:
Ionic CLI Version: 2.0.0-beta.37
Ionic App Lib Version: 2.0.0-beta.20
ios-deploy version: 1.8.6
ios-sim version: 5.0.8
OS: Mac OS X El Capitan
Node Version: v4.4.7
Xcode version: Xcode 7.3.1 Build version 7D1014

Did you resolve this? I am having exactly the same problem…

Can you run ionic info in the root directory of your project and paste the output here? Also, what version of ionic-native are you using?