ionic2 - Runtime Error Cannot find module "ionic-native" IONIC 2 -


i have been trying add banner ads new ionic 2 apps display bellow error. doing shown here tutorial. when run browser using ionic serve -l -c showing runtime error cannot find module "ionic-native" error bellow,

enter image description here

here myapp.component.ts files code

import { component } '@angular/core'; import { platform } 'ionic-angular'; import { statusbar } '@ionic-native/status-bar'; import { splashscreen } '@ionic-native/splash-screen'; import { geolocation } '@ionic-native/geolocation'; import { admob } 'ionic-native';   import { homepage } '../pages/home/home'; import { detailspage } '../pages/details/details'; import { settingmodalpage } '..pages/setting-modal/setting- modal';   @component({ templateurl: 'app.html' }) export class myapp { rootpage:any = homepage;  constructor(platform: platform, statusbar: statusbar, splashscreen:  splashscreen) { platform.ready().then(() => {   // okay, platform ready , our plugins available.   // here can higher level native things might need.   statusbar.styledefault();   splashscreen.hide();    let options = {     adid: 'ca-app-pub-5732334124058455/7973166445',     adsize: 'smart_banner',     istesting: false   };    admob.createbanner(options).then(() => {     admob.showbanner(8);   });   }); } } 

in package.json file,

 "dependencies": { "@angular/common": "2.4.8", "@angular/compiler": "2.4.8", "@angular/compiler-cli": "2.4.8", "@angular/core": "2.4.8", "@angular/forms": "2.4.8", "@angular/http": "2.4.8", "@angular/platform-browser": "2.4.8", "@angular/platform-browser-dynamic": "2.4.8", "@angular/platform-server": "2.4.8", "@ionic-native/admob": "^3.4.4", "@ionic-native/core": "^3.1.0", "@ionic-native/geolocation": "^3.4.4", "@ionic-native/launch-navigator": "^3.4.4", "@ionic-native/splash-screen": "3.1.0", "@ionic-native/status-bar": "3.1.0", "@ionic/storage": "2.0.0", "font-awesome": "^4.7.0", "ionic-angular": "2.3.0", "ionic2-rating": "^1.2.0", "ionicons": "3.0.0", "rxjs": "5.0.1", "sw-toolbox": "3.4.0", "zone.js": "0.7.2"   },   "devdependencies": { "@ionic/app-scripts": "1.1.4", "typescript": "2.0.9"   },   "cordovaplugins": [ "cordova-plugin-whitelist", "cordova-plugin-console", "cordova-plugin-statusbar", "cordova-plugin-device", "cordova-plugin-splashscreen", "ionic-plugin-keyboard" ], 

check here.

import { admob } 'ionic-native'; 

was in ionic-native 2.x.

do:

ionic plugin add cordova-plugin-admobpro --save npm install --save @ionic-native/admob 

and:

import { admob, admoboptions, adsize, adextras} '@ionic-native/admob';//import  constructor(platform: platform, statusbar: statusbar, splashscreen:  splashscreen,admob:admob)//inject in constructor.     //and use    let options:admoboptions={     adid: 'ca-app-pub-5732334124058455/7973166445',     adsize: 'smart_banner',     istesting: false    }    this.admob.createbanner(options).then(()=>{        this.admob.showbanner(8)    }) 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -