如何在Electron项目中实现nfc阅读器(ACR122)? [英] How do I implement a nfc reader (ACR122) to an Electron project?

查看:414
本文介绍了如何在Electron项目中实现nfc阅读器(ACR122)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经下载了该库( https://github.com/pokusew/nfc-pcsc),现在我正在尝试在其中运行一个Electron项目,但是当我尝试将其作为Electron项目运行时,却给我带来了很多麻烦. 所以我的问题是:我该如何在我的Electron项目上实现该库并使它不能作为node.js使用

I have downloaded this library (https://github.com/pokusew/nfc-pcsc) and now i'm trying to run an Electron project in it, but is giving me everytime problems when i try to run it as an Electron project. So my question is: How can I implement this library on my Electron project and make it work not as node.js

我试图在库中npm install --save electron@latest并在json上将脚本"example": "node -r @babel/register examples/read-write.js"更改为"example": "electron -r @babel/register examples/read-write.js",我也试图卸载并安装,我已经完成了电子重建

I tried to npm install --save electron@latest in the library and change on the json the script "example": "node -r @babel/register examples/read-write.js" to "example": "electron -r @babel/register examples/read-write.js" also i have tried to uninstall and install, i have done electron-rebuild

    "rebuild": "electron-rebuild -f -w yourmodule",
    "build": "babel src --out-dir dist",
    "example": "electron -r @babel/register examples/read-write.js",
    "example-basic": "node -r @babel/register examples/basic.js",
    "example-from-readme-3": "node -r @babel/register examples/from-readme-3.js",
    "example-led": "node -r @babel/register examples/led.js",
    "example-mifare-classic": "node -r @babel/register examples/mifare-classic.js",
    "example-mifare-desfire": "node -r @babel/register examples/mifare-desfire.js",
    "example-mifare-ultralight-ntag": "node -r @babel/register examples/mifare-ultralight-ntag.js",
    "example-ndef": "node -r @babel/register examples/ndef.js",
    "example-uid-logger": "node -r @babel/register examples/uid-logger.js",
    "example-without-auto": "node -r @babel/register examples/without-auto.js",
    "prepack": "yarn build && yarn test",
    "test": "cross-env NODE_ENV=test ava test/tests.js --verbose"
  } 

当我尝试将应用程序作为Electron应用程序运行时出现此错误( https: //i.imgur.com/UhSjlo6.png ),当我进行重建时,我会遇到以下错误:×重建失败电子重建内部发生未处理的错误

I'm getting this error when i'm trying to run the app as Electron app (https://i.imgur.com/UhSjlo6.png) and when i do the rebuild i have this error: × Rebuild Failed An unhandled error occurred inside electron-rebuild

推荐答案

从v5.0.0开始的电子版本正在使用Node.js v12.0.0.无法为该版本正确构建本机模块(nfc-pcsc).

Electron as of v5.0.0 is using Node.js v12.0.0. This native module (nfc-pcsc) is not building correctly for that version.

将Electron降级为v4,通过"electron-rebuild"进行重建,并且应该可以正确构建.

Downgrade Electron to v4, rebuild via "electron-rebuild" and it should build properly.

npm install --save-dev electron@4

然后

electron-rebuild

这篇关于如何在Electron项目中实现nfc阅读器(ACR122)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆