Updating plugin in Ionic 3

#1

Hi, i want to update phonegap-nfc plugin to version 1.0.3, so i can use reader mode in my app. How do i do that? Do i simply use npm install @latest on phonegap-nfc plugin? And what about the ionic native wrapper, do i have to update it also? I tried that, i install latest version of phonegap-nfc plugin and ionic-native/nfc , but now nfc in my app is broken. Any ideas how to do this update properly?

This is how my package.json looks like at the start:

{
  "name": "ionic-hello-world",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "5.0.0",
    "@angular/compiler": "5.0.0",
    "@angular/compiler-cli": "5.0.0",
    "@angular/core": "5.0.0",
    "@angular/forms": "5.0.0",
    "@angular/http": "5.0.0",
    "@angular/platform-browser": "5.0.0",
    "@angular/platform-browser-dynamic": "5.0.0",
    "@ionic-native/app-minimize": "^4.4.2",
    "@ionic-native/barcode-scanner": "^4.5.2",
    "@ionic-native/core": "^4.3.2",
    "@ionic-native/device": "^4.5.2",
    "@ionic-native/geolocation": "^4.3.2",
    "@ionic-native/native-storage": "^4.3.2",
    "@ionic-native/network": "^4.3.2",
    "@ionic-native/nfc": "^4.3.2",
    "@ionic-native/splash-screen": "^4.3.2",
    "@ionic-native/sqlite": "^4.3.2",
    "@ionic-native/status-bar": "^4.3.2",
    "@ionic/storage": "2.1.3",
    "android-versions": "^1.2.1",
    "cordova-android": "6.3.0",
    "cordova-plugin-appminimize": "^1.0.0",
    "cordova-plugin-certificates": "^0.6.4",
    "cordova-plugin-compat": "^1.2.0",
    "cordova-plugin-console": "^1.1.0",
    "cordova-plugin-device": "^1.1.7",
    "cordova-plugin-geolocation": "^2.4.3",
    "cordova-plugin-nativestorage": "^2.2.2",
    "cordova-plugin-network-information": "^1.3.4",
    "cordova-plugin-splashscreen": "^4.1.0",
    "cordova-plugin-statusbar": "^2.3.0",
    "cordova-plugin-whitelist": "^1.3.3",
    "cordova-sqlite-storage": "^2.1.2",
    "hex2dec": "^1.0.1",
    "ionic": "^3.16.0",
    "ionic-angular": "^3.9.2",
    "ionic-plugin-keyboard": "^2.2.1",
    "ionicons": "3.0.0",
    "moment": "^2.18.1",
    "phonegap-nfc": "^0.7.1",
    "phonegap-plugin-barcodescanner": "^7.0.0",
    "rxjs": "5.5.2",
    "sw-toolbox": "3.4.0",
    "xml2js": "^0.4.17",
    "zone.js": "0.8.18"
  },
  "devDependencies": {
    "@ionic/app-scripts": "3.1.0",
    "ionic": "3.13.2",
    "retyped-xml2js-tsd-ambient": "0.0.0-0",
    "typescript": "^2.6.1"
  },
  "cordovaPlugins": [
    "cordova-plugin-whitelist",
    "cordova-plugin-console",
    "cordova-plugin-statusbar",
    "cordova-plugin-device",
    "cordova-plugin-splashscreen",
    "ionic-plugin-keyboard"
  ],
  "cordovaPlatforms": [],
  "description": "dochazka: An Ionic project",
  "cordova": {
    "platforms": [
      "android"
    ],
    "plugins": {
      "ionic-plugin-keyboard": {},
      "cordova-plugin-whitelist": {},
      "cordova-plugin-console": {},
      "cordova-plugin-device": {},
      "cordova-plugin-geolocation": {
        "GEOLOCATION_USAGE_DESCRIPTION": "To locate you"
      },
      "cordova-plugin-nativestorage": {},
      "cordova-plugin-network-information": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-statusbar": {},
      "cordova-sqlite-storage": {},
      "phonegap-nfc": {},
      "cordova-plugin-appminimize": {},
      "phonegap-plugin-barcodescanner": {},
      "cordova-plugin-certificates": {}
    }
  }
}
#2

I do not know why, my plugins for the version 3 of ionic, must be in version 4.x.x, for that, I had to delete the whole plugin with:

  • npm uninstall @ ionic-native / plugin-name;
  • ionic cordova plugin rm cordova-plugin-name
    Then:
    — ionic cordova plugin rm cordova-plugin-name
    — npm uninstall @ ionic-native / plugin-name @ 4;

The @ 4 of @ ionic-native / plugin-name @ 4 is to install vesion 4, version 5 plugins do not work on ionic 3.

If you want a precise version of what you need to do:
— @ ionic-native / plugin-name @ x.x.x