找不到 Ionic 2 插件问题
Ionic 2 plugin not found Issue
我使用的是最新版本的 Ionic 2。这是我的 ionic package.json
{
"name": "ionic-hello-world",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"build": "ionic-app-scripts build",
"watch": "ionic-app-scripts watch",
"serve:before": "watch",
"emulate:before": "build",
"deploy:before": "build",
"build:before": "build",
"run:before": "build"
},
"dependencies": {
"@angular/common": "^2.1.0",
"@angular/compiler": "^2.1.0",
"@angular/compiler-cli": "^2.1.0",
"@angular/core": "^2.1.0",
"@angular/forms": "^2.1.0",
"@angular/http": "^2.1.0",
"@angular/platform-browser": "^2.1.0",
"@angular/platform-browser-dynamic": "^2.1.0",
"@angular/platform-server": "^2.1.0",
"ionic-angular": "^2.0.0-rc.1",
"ionicons": "^3.0.0",
"@ionic/storage": "^1.1.6",
"ionic-native": "^2.2.2",
"rxjs": "^5.0.0-rc.1",
"zone.js": "^0.6.25"
},
"devDependencies": {
"@ionic/app-scripts": "^0.0.30",
"typescript": "^2.0.3"
},
"description": "SSRetail: An Ionic project",
"cordovaPlugins": [
"cordova-plugin-device",
"cordova-plugin-console",
"cordova-plugin-whitelist",
"cordova-plugin-splashscreen",
"cordova-plugin-statusbar",
"ionic-plugin-keyboard"
],
"cordovaPlatforms": []
}
我安装了一个插件"cordova-plugin-nativestorage",从ionic-native导入了"NativeStorage"并在项目中使用。
片段:
setConnectionInfo() {
NativeStorage.setItem('myitem', { property: 'value', anotherProperty: 'anotherValue' })
.then(
() => console.log('Stored item!'),
error => console.error('Error storing item', error)
);
}
但是当我 运行 它在我的模拟器中使用 "ionic run android -c -l" 时,我收到一个错误,提示找不到插件,请安装插件!
LAUNCH SUCCESS
0 882136 log Hello ConnectionService Provider
1 882133 warn Native: tried calling t.setItem, but the t plugin is not installed.
2 882134 warn Install the t plugin: 'ionic plugin add cordova—plugin—nativestorage'
3 882261 error Error storing item, plugin_not_installed
4 882261 log DEVICE READY FIRED AFTER, 195, ms
Ionic server commands, enter:
rezta t or m to restart the client app from the root
请指教。谢谢你。出于某种原因,我添加了插件,但 package.json 文件没有使用新的 cordova 插件进行更新。
离子信息
您的系统信息:
Cordova CLI: 6.3.1
Gulp version: CLI version 3.9.1
Gulp local:
Ionic Framework Version: 2.6.9-rc.6—261616131811
Ionic CLI Version: 2.1.0
Ionic App Lib Version: 2.1.6—beta.1
OS: windows 7 SP1
Node Version: v6.2.9
从您提供的错误图像来看,您似乎在 deviceready 触发之前尝试使用函数。用 platform.ready() 包装你的方法调用,它应该可以工作。干杯。
我使用的是最新版本的 Ionic 2。这是我的 ionic package.json
{
"name": "ionic-hello-world",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"build": "ionic-app-scripts build",
"watch": "ionic-app-scripts watch",
"serve:before": "watch",
"emulate:before": "build",
"deploy:before": "build",
"build:before": "build",
"run:before": "build"
},
"dependencies": {
"@angular/common": "^2.1.0",
"@angular/compiler": "^2.1.0",
"@angular/compiler-cli": "^2.1.0",
"@angular/core": "^2.1.0",
"@angular/forms": "^2.1.0",
"@angular/http": "^2.1.0",
"@angular/platform-browser": "^2.1.0",
"@angular/platform-browser-dynamic": "^2.1.0",
"@angular/platform-server": "^2.1.0",
"ionic-angular": "^2.0.0-rc.1",
"ionicons": "^3.0.0",
"@ionic/storage": "^1.1.6",
"ionic-native": "^2.2.2",
"rxjs": "^5.0.0-rc.1",
"zone.js": "^0.6.25"
},
"devDependencies": {
"@ionic/app-scripts": "^0.0.30",
"typescript": "^2.0.3"
},
"description": "SSRetail: An Ionic project",
"cordovaPlugins": [
"cordova-plugin-device",
"cordova-plugin-console",
"cordova-plugin-whitelist",
"cordova-plugin-splashscreen",
"cordova-plugin-statusbar",
"ionic-plugin-keyboard"
],
"cordovaPlatforms": []
}
我安装了一个插件"cordova-plugin-nativestorage",从ionic-native导入了"NativeStorage"并在项目中使用。
片段:
setConnectionInfo() {
NativeStorage.setItem('myitem', { property: 'value', anotherProperty: 'anotherValue' })
.then(
() => console.log('Stored item!'),
error => console.error('Error storing item', error)
);
}
但是当我 运行 它在我的模拟器中使用 "ionic run android -c -l" 时,我收到一个错误,提示找不到插件,请安装插件!
LAUNCH SUCCESS
0 882136 log Hello ConnectionService Provider
1 882133 warn Native: tried calling t.setItem, but the t plugin is not installed.
2 882134 warn Install the t plugin: 'ionic plugin add cordova—plugin—nativestorage'
3 882261 error Error storing item, plugin_not_installed
4 882261 log DEVICE READY FIRED AFTER, 195, ms
Ionic server commands, enter:
rezta t or m to restart the client app from the root
请指教。谢谢你。出于某种原因,我添加了插件,但 package.json 文件没有使用新的 cordova 插件进行更新。
离子信息
您的系统信息:
Cordova CLI: 6.3.1
Gulp version: CLI version 3.9.1
Gulp local:
Ionic Framework Version: 2.6.9-rc.6—261616131811
Ionic CLI Version: 2.1.0
Ionic App Lib Version: 2.1.6—beta.1
OS: windows 7 SP1
Node Version: v6.2.9
从您提供的错误图像来看,您似乎在 deviceready 触发之前尝试使用函数。用 platform.ready() 包装你的方法调用,它应该可以工作。干杯。