chariotsolutions / phonegap-nfc

PhoneGap NFC Plugin
MIT License
703 stars 547 forks source link

Ionic NFC dependencies #459

Open giuliastully opened 2 years ago

giuliastully commented 2 years ago

I'm trying to add NFC plugin to my blank Ionic app.
I use this instruction to install:

    ionic cordova plugin add phonegap-nfc.  
    npm install @ionic-native/nfc

I add import line to app.module.js and add NFC and Ndef to providers:

   import { NFC, Ndef } from "@ionic-native/nfc/ngx";

    @NgModule({
    declarations: [AppComponent],
    entryComponents: [],
    imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule],
    providers: [{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }, NFC, Ndef,],
    bootstrap: [AppComponent],
    })
    export class AppModule { }

but when I use "ionic serve" or "ionic cordova build android" i got this error:

An error occurred during the build:
    Error: The target entry-point "@ionic-native/nfc" has missing dependencies:
      - @ionic-native/core
    ...
    ...

How can I solve it?

This is my package.json:

   {
        "name": "example2",
        "version": "0.0.1",
        "author": "Ionic Framework",
        "homepage": "https://ionicframework.com/",
        "scripts": {
        "ng": "ng",
        "start": "ng serve",
        "build": "ng build",
        "test": "ng test",
        "lint": "ng lint",
        "e2e": "ng e2e"
        },
        "private": true,
        "dependencies": {
        "@angular/common": "~12.1.1",
        "@angular/core": "~12.1.1",
        "@angular/forms": "~12.1.1",
        "@angular/platform-browser": "~12.1.1",
        "@angular/platform-browser-dynamic": "~12.1.1",
        "@angular/router": "~12.1.1",
        "@ionic-native/nfc": "^5.36.0",
        "@ionic/angular": "^5.5.2",
        "cordova-android": "9.1.0",
        "rxjs": "~6.6.0",
        "tslib": "^2.2.0",
        "zone.js": "~0.11.4"
        },
        "devDependencies": {
        "@angular-devkit/build-angular": "~12.1.1",
        "@angular-eslint/builder": "~12.0.0",
        "@angular-eslint/eslint-plugin": "~12.0.0",
        "@angular-eslint/eslint-plugin-template": "~12.0.0",
        "@angular-eslint/template-parser": "~12.0.0",
        "@angular/cli": "~12.1.1",
        "@angular/compiler": "~12.1.1",
        "@angular/compiler-cli": "~12.1.1",
        "@angular/language-service": "~12.0.1",
        "@ionic/angular-toolkit": "^4.0.0",
        "@types/jasmine": "~3.6.0",
        "@types/jasminewd2": "~2.0.3",
        "@types/node": "^12.11.1",
        "@typescript-eslint/eslint-plugin": "4.16.1",
        "@typescript-eslint/parser": "4.16.1",
        "cordova-plugin-device": "^2.0.2",
        "cordova-plugin-ionic-keyboard": "^2.2.0",
        "cordova-plugin-ionic-webview": "^4.2.1",
        "cordova-plugin-splashscreen": "^5.0.2",
        "cordova-plugin-statusbar": "^2.4.2",
        "cordova-plugin-whitelist": "^1.3.3",
        "eslint": "^7.6.0",
        "eslint-plugin-import": "2.22.1",
        "eslint-plugin-jsdoc": "30.7.6",
        "eslint-plugin-prefer-arrow": "1.2.2",
        "jasmine-core": "~3.8.0",
        "jasmine-spec-reporter": "~5.0.0",
        "karma": "~6.3.2",
        "karma-chrome-launcher": "~3.1.0",
        "karma-coverage": "~2.0.3",
        "karma-coverage-istanbul-reporter": "~3.0.2",
        "karma-jasmine": "~4.0.0",
        "karma-jasmine-html-reporter": "^1.5.0",
        "phonegap-nfc": "^1.2.0",
        "protractor": "~7.0.0",
        "ts-node": "~8.3.0",
        "typescript": "~4.2.4"
        },
        "description": "An Ionic project",
        "cordova": {
        "plugins": {
            "cordova-plugin-whitelist": {},
            "cordova-plugin-statusbar": {},
            "cordova-plugin-device": {},
            "cordova-plugin-splashscreen": {},
            "cordova-plugin-ionic-webview": {
            "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
            },
            "cordova-plugin-ionic-keyboard": {},
            "phonegap-nfc": {}
        },
        "platforms": [
            "android"
        ]
        }
    }
phpfs commented 2 years ago

Did you try this updated guide for ionic with capacitorJS? https://ionicframework.com/docs/native/nfc

chegewara commented 2 years ago

how about: npm install @ionic-native/core?