模块没有导出成员"IonicNativePlugin",Ionic2



我正在尝试获取相机,文件,filepath和传输插件工作,我正在为每个错误遇到此错误,

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"

我想念什么吗?

ionicnativePlugin可与Ionic-native/Core最新版本(3.6.1(一起使用,因此您必须更新到最新版本。

在您的项目目录中键入此命令:

npm install @ionic-native/core --save

解决问题。

我找到了解决方案,ionicnativePlugin已在较新版本的Ionic-native/core中添加,因此我必须卸载此解决方案并安装最新的3.6.1,现在插件被导出,一切正常。

尝试以下:

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

npm卸载-Save @ionic-native/coreNPM安装-Save @ionic-native/core @最新

执行此操作,然后关闭所有内容,包括命令提示符,然后再次打开并运行。问题是求解器

如果您提供TS代码将有助于此问题。另外,由于您说您有最新的Angular2,我认为您正在使用离子3.x.x,如果您提供离子信息会更有帮助。

这是您应该如何导入和使用相机,文件,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

然后,您可以在页面TS 上导入插件:

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]

相关内容

  • 没有找到相关文章

最新更新