TypeError: Cannot read property 'then' of undefined while using ionic-v4 with Sqlite



I am a newbie in ionic. I am trying to create a simple app with ionic + sqlite db.
But, every time I run I am getting the following error.

core.js:15714 ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'then' of undefined
TypeError: Cannot read property 'then' of undefined

here is the app.component.ts

import { Component } from '@angular/core';

import { Platform } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';
import { SQLite, SQLiteObject } from '@ionic-native/sqlite/ngx';

  selector: 'app-root',
  templateUrl: 'app.component.html'
export class AppComponent {

   private db: SQLiteObject;

    private platform: Platform,
    private splashScreen: SplashScreen,
    private statusBar: StatusBar, 
    private sqlite: SQLite

  ) {

  initializeApp() {
    this.platform.ready().then(() => {

  private createDB() {
     alert('database creating')
      name: 'myDB.db',
      location: 'default'
    .then((db: SQLiteObject) => {
      alert('database created')
      this.db = db;
      // this.createTable();
    .catch(e => alert(e));

can anybody help me to solve this.



I also have the same problem, so far I still can’t fix it.


If you are running in a browser (ionic serve) , look in the Console. You will probably see thiis just before your error:

Native: tried accessing the SQLite plugin but Cordova is not available. Make sure to include cordova.js or run in a device/simulator

SQlite is a Cordova plugin and Cordova must be avalable


Thanks for the explanation. That helped :slight_smile: