ionic3.9.2 runtime error with cordova imported -
i'm trying use cordova-plugin-inappbrowser ionic project,but when have installed dependencies , run "ionic serve",it seems this
error: cannot find module "." @ webpackmissingmodule (http://localhost:8100/build/vendor.js:95121:70) @ object.get (http://localhost:8100/build/vendor.js:95121:148) @ object.module.exports.obj (http://localhost:8100/build/vendor.js:173422:29) @ __webpack_require__ (http://localhost:8100/build/vendor.js:55:30) @ object.298 (http://localhost:8100/build/main.js:192:66) @ __webpack_require__ (http://localhost:8100/build/vendor.js:55:30) @ object.294 (http://localhost:8100/build/main.js:46:67) @ __webpack_require__ (http://localhost:8100/build/vendor.js:55:30) @ object.448 (http://localhost:8100/build/main.js:335:75) @ __webpack_require__ (http://localhost:8100/build/vendor.js:55:30) here package.json
{ "name": "ionicdemo2", "version": "0.0.1", "author": "ionic framework", "homepage": "http://ionicframework.com/", "private": true, "scripts": { "clean": "ionic-app-scripts clean", "build": "ionic-app-scripts build", "lint": "ionic-app-scripts lint", "ionic:build": "ionic-app-scripts build", "ionic:serve": "ionic-app-scripts serve" }, "dependencies": { "@angular/common": "4.1.3", "@angular/compiler": "4.1.3", "@angular/compiler-cli": "4.1.3", "@angular/core": "4.1.3", "@angular/forms": "4.1.3", "@angular/http": "4.1.3", "@angular/platform-browser": "4.1.3", "@angular/platform-browser-dynamic": "4.1.3", "@ionic-native/core": "3.12.1", "@ionic-native/splash-screen": "3.12.1", "@ionic-native/status-bar": "3.12.1", "@ionic/storage": "2.0.1", "child_process": "^1.0.2", "cordova": "^7.0.1", "cordova-android": "^6.2.3", "cordova-ios": "^4.4.0", "cordova-plugin-console": "^1.0.5", "cordova-plugin-device": "^1.1.4", "cordova-plugin-inappbrowser": "^1.7.1", "cordova-plugin-splashscreen": "^4.0.3", "cordova-plugin-statusbar": "^2.2.2", "cordova-plugin-whitelist": "^1.3.1", "ionic-angular": "3.6.0", "ionic-plugin-keyboard": "^2.2.1", "ionicons": "3.0.0", "rxjs": "5.4.0", "sw-toolbox": "3.6.0", "unorm": "^1.4.1", "xcode": "^0.9.3", "zone.js": "0.8.12" }, "devdependencies": { "@ionic/app-scripts": "2.1.3", "@ionic/cli-plugin-ionic-angular": "1.0.0-rc.2", "typescript": "2.3.4" }, "description": "an ionic project", "cordova": { "plugins": { "cordova-plugin-inappbrowser": {}, "cordova-plugin-console": {}, "cordova-plugin-device": {}, "cordova-plugin-splashscreen": {}, "cordova-plugin-statusbar": {}, "cordova-plugin-whitelist": {}, "ionic-plugin-keyboard": {} }, "platforms": [ "android", "ios" ] } } and config.xml
······ <plugin name="ionic-plugin-keyboard" spec="~2.2.1" /> <plugin name="cordova-plugin-whitelist" spec="1.3.1" /> <plugin name="cordova-plugin-console" spec="1.0.5" /> <plugin name="cordova-plugin-statusbar" spec="2.2.2" /> <plugin name="cordova-plugin-device" spec="1.1.4" /> <plugin name="cordova-plugin-splashscreen" spec="~4.0.1" /> <plugin name="cordova-plugin-inappbrowser" spec="^1.7.1" /> <engine name="ios" spec="~4.4.0" /> <engine name="android" spec="~6.2.3" /> </widget> and xx.ts
import { component } '@angular/core'; import { navcontroller } 'ionic-angular'; import { cordova } 'cordova'; @component({ selector: 'page-try', templateurl: 'try.html' }) export class trypage { constructor(public navctrl: navcontroller) { cordova.inappbrowser.open('http://www.someweb.com', '_blank', 'location=yes') } } "ionic serve" works fine me,and try "npm install --save ." problem still!!! please help! thks
importing cordova not correct way of using cordova-plugins in ionic. have install ionic-native wrapper plugin want use. see ionics documentation inappbrowser plugin.
if want use plugin has not yet wrapper available can follows: @ top of file (e.g. somewhere below imports) add:
declare var nameofthejsmodule you can find name of js-module in plugin.xml of plugin under name property:
<js-module src="www/inappbrowser.js" name="inappbrowser"> ... </js-module> so in case:
delcare var inappbrowser; and use e.g.:
this.inappbrowser.show(); anyway, highly recommend using ionic-native injectables way more convinient use because provide common interface every plugin (the response callbacks wrapped in promise or observable), e.g. ensures angulars change-detection triggered. additionally code completion useful.
Comments
Post a Comment