pokusew / nfc-pcsc

Easy reading and writing NFC tags and cards in Node.js
MIT License
535 stars 132 forks source link

It turned out to connect the library in CRA(React)? #152

Open GABuryan opened 9 months ago

GABuryan commented 9 months ago

I used create-react-app (webpack 5). Errors on compilation.

If const {NFC} = require('nfc-pcsc') , then error : Uncaught TypeError: Cannot read properties of undefined (reading 'default') at Object.get [as NFC]

if

const NFC = require('nfc-pcsc')
  const nfc = new NFC()

then error : Uncaught TypeError: NFC is not a constructor

How to solve the problem?

alexgoto commented 9 months ago

@GABuryan

This module provides access to Smart Cards only from Node.js context. React is context of web browser.

You can not interact with OS Smart Card API directly on machine which uploads your JavaScript in self browser.

User browser need to install some sort of additional 'interface' for this. For example an extension.