0

I'm creating an app with Ionic 2 that runs as a website in a browser and as an app on iOS and Android. It uses the SQLite plugin when on mobile devices. The issue I'm having is the SQLite plugin has to import ionic-native stuff, which when running as a website throws an error because ionic-native is only on cordova devices. How do I get around this?

The import that is causing the error:

import { SQLite, SQLiteObject } from '@ionic-native/sqlite';

and the error that is thrown:

Cannot find module "@ionic-native/core"

Jake
  • 383
  • 6
  • 26

2 Answers2

2

Opps. I thought it was because ionic-native wasn't being included in my non-cordova platform. But I just needed to install the core package with npm install @ionic-native/core --save

Jake
  • 383
  • 6
  • 26
1

Got the same error, but with a different module(InAppBrowser). This code solved it for me.

in app.module.ts add:

import { InAppBrowser } from '@ionic-native/in-app-browser';    

@NgModule({
 declarations: [
 ...
 ]
 providers: [
 ...
 InAppBrowser,
 ...
 ],

and .ts file i use this:

import { InAppBrowser } from '@ionic-native/in-app-browser';

constructor(private iab: InAppBrowser) {}