模块没有导出的成员' IonicNativePlugin',Ionic2

时间:2017-04-27 07:01:06

标签: cordova ionic2

我正在尝试将相机,文件,文件路径和传输插件工作,我收到这些错误,

Module 'node_modules/@ionic-native/core/index' has no exported member 'IonicNativePlugin'

我得到了最新的Ionic2版本。

按要求提供package.json文件

"dependencies": {
"@angular/common": "4.0.0",
"@angular/compiler": "4.0.0",
"@angular/compiler-cli": "4.0.0",
"@angular/core": "4.0.0",
"@angular/forms": "4.0.0",
"@angular/http": "4.0.0",
"@angular/platform-browser": "4.0.0",
"@angular/platform-browser-dynamic": "4.0.0",
"@ionic-native/camera": "^3.6.0",
"@ionic-native/core": "3.4.2",
"@ionic-native/file": "^3.6.0",
"@ionic-native/file-path": "^3.6.0",
"@ionic-native/splash-screen": "3.4.2",
"@ionic-native/status-bar": "3.4.2",
"@ionic-native/transfer": "^3.6.0",
"@ionic/storage": "2.0.1",
"crypto-js": "3.1.9-1",
"fast-sha256": "1.0.0",
"ionic-angular": "3.0.1",
"ionic-native": "^3.5.0",
"ionicons": "3.0.0",
"rxjs": "5.1.1",
"sha256": "0.2.0",
"sw-toolbox": "3.4.0",
"ts-md5": "1.2.0",
"zone.js": "^0.8.4"

devDependencies": {
    "@ionic/app-scripts": "1.3.0",
    "typescript": "~2.2.1"

"cordovaPlugins": [
    "cordova-plugin-whitelist",
    "cordova-plugin-console",
    "cordova-plugin-statusbar",
    "cordova-plugin-device",
    "ionic-plugin-keyboard",
    "cordova-plugin-splashscreen"

"cordovaPlatforms": [],
  "description": "Work: An Ionic project"
我错过了什么吗?

5 个答案:

答案 0 :(得分:4)

IonicNativePlugin适用于ionic-native / core最新版本(3.6.1),因此您必须更新到最新版本。

在项目目录中输入以下命令:

npm install @ionic-native/core --save

问题解决了。

答案 1 :(得分:2)

我找到了解决方案,IonicNativePlugin被添加到更新版本的ionic-native / core中,所以我不得不卸载这个并安装最新版本的3.6.1,现在插件已导出,一切正常。

答案 2 :(得分:2)

试试这个:

npm uninstall --save @ionic-native/core
npm install --save @ionic-native/core@latest

答案 3 :(得分:1)

npm uninstall --save @ ionic-native / core npm install --save @ ionic-native / core @ latest

执行此操作,然后关闭包括命令提示符在内的所有内容,然后重新打开并运行。问题是解决者

答案 4 :(得分:0)

如果您提供ts代码,将有助于解决此问题。另外,既然你说你有最新的angular2我假设你使用离子3.x.x,如果你提供你的离子信息会更有帮助。

以下是如何导入和使用Camera,File,FilePath本机插件。

首先确保已安装插件:

$ ionic plugin add cordova-plugin-camera
$ npm install --save @ionic-native/camera

$ ionic plugin add cordova-plugin-file
$ npm install --save @ionic-native/file

$ ionic plugin add cordova-plugin-filepath
$ npm install --save @ionic-native/file-path

然后您在 页面 中导入插件,如下所示:

import { Camera } from '@ionic-native/camera';
import { File } from '@ionic-native/file';
import { FilePath } from '@ionic-native/file-path';

确保您还在app.module.ts

中添加了提供程序
//at the top import the plugins
import { File } from '@ionic-native/file';
import { FilePath } from '@ionic-native/file-path';
import { Camera } from '@ionic-native/camera';

...

//inject your plugins in the providers at the bottom of your app.module.ts
providers: [{provide: ErrorHandler, useClass: IonicErrorHandler},  File, FilePath, Camera]