Remove bindings dependency (require the built addon directly because the build output location is well-known and constant)
Add note about a possible error and its solution to the README Improve .editorconfig Run tests in CI workflow
This commit is contained in:
@@ -9,13 +9,9 @@ charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[package.json]
|
||||
[{package.json, *.yaml, *.yml}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -21,3 +21,5 @@ jobs:
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
- name: Compile
|
||||
run: npm install --verbose
|
||||
- name: Run tests
|
||||
run: npm test
|
||||
|
||||
4
.idea/dictionaries/pokusew.xml
generated
4
.idea/dictionaries/pokusew.xml
generated
@@ -1,13 +1,17 @@
|
||||
<component name="ProjectDictionaryState">
|
||||
<dictionary name="pokusew">
|
||||
<words>
|
||||
<w>addon</w>
|
||||
<w>addons</w>
|
||||
<w>debian</w>
|
||||
<w>doctoc</w>
|
||||
<w>gitignore</w>
|
||||
<w>npmignore</w>
|
||||
<w>pcsc</w>
|
||||
<w>pcsclite</w>
|
||||
<w>picc</w>
|
||||
<w>pokusew</w>
|
||||
<w>scard</w>
|
||||
</words>
|
||||
</dictionary>
|
||||
</component>
|
||||
@@ -33,5 +33,6 @@ nbproject/private/
|
||||
# node, npm
|
||||
node_modules/
|
||||
|
||||
# built Node.js C++ addon
|
||||
# built Node.js C++ addon (must be build specifically on the target platform,
|
||||
# which is done automatically during installation via node-gyp)
|
||||
/build/
|
||||
|
||||
30
README.md
30
README.md
@@ -42,6 +42,8 @@ Bindings over pcsclite to access Smart Cards. It works in **Linux**, **macOS** a
|
||||
- [Disabling drivers to make pcsclite working on Linux](#disabling-drivers-to-make-pcsclite-working-on-linux)
|
||||
- [Which Node.js versions are supported?](#which-nodejs-versions-are-supported)
|
||||
- [Can I use this library in my React Native app?](#can-i-use-this-library-in-my-react-native-app)
|
||||
- [Frequent errors](#frequent-errors)
|
||||
- [Error: Cannot find module '../build/Release/pcsclite.node'](#error-cannot-find-module-buildreleasepcsclitenode)
|
||||
- [License](#license)
|
||||
|
||||
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
||||
@@ -345,6 +347,34 @@ or in **Electron.js and NW.js** desktop apps. On the other hand, these requireme
|
||||
On top of that, React Native does not contain any Node.js runtime.
|
||||
|
||||
|
||||
## Frequent errors
|
||||
|
||||
### Error: Cannot find module '../build/Release/pcsclite.node'
|
||||
|
||||
@pokusew/pcsclite uses **Node Native Modules** (Node.js C++ Addon) to access PC/SC API (pcsclite).
|
||||
The Node.js native C++ addon is built during installation via [node-gyp](https://github.com/nodejs/node-gyp)
|
||||
(see package.json > scripts > [install](https://github.com/pokusew/node-pcsclite/blob/master/package.json#L37)).
|
||||
When you see the error `Cannot find module '../build/Release/pcsclite.node'`, something probably
|
||||
**went wrong during the installation**.
|
||||
|
||||
Follow the steps below to resolve your problem:
|
||||
1. If **there are any errors** in the output of the `npm install` resp. `yarn install`,
|
||||
* **ensure you meet all the requirements** described in the [Installation](#installation) section of this README.
|
||||
Then try reinstalling @pokusew/pcsclite (npm uninstall / yarn remove and then npm install / yarn add).
|
||||
* **If the problem persists**, [open a new issue](https://github.com/pokusew/node-pcsclite/issues/new)
|
||||
and be sure to include the output of the `npm install` resp. `yarn install`
|
||||
and the details about your platform, OS, Node.js version and npm/yarn version.
|
||||
2. If **there are no errors** during the installation,
|
||||
* then try reinstalling @pokusew/pcsclite (npm uninstall / yarn remove and then npm install / yarn add).
|
||||
* If it does not help, then examine the contents of the folder `node_modules/@pokusew/pcsclite` in your project
|
||||
(in case you installed @pokusew/pcsclite as a dependency). There should be a `build` folder with
|
||||
a `Release` folder inside. In the `Release` folder, there should be a `pcsclite.node` file.
|
||||
It is possible that this file is somewhere else. Whether you find the file somewhere or not,
|
||||
please [open a new issue](https://github.com/pokusew/node-pcsclite/issues/new)
|
||||
and describe the problem and be sure to include the details
|
||||
about your platform, OS, Node.js version and npm/yarn version.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
[ISC](/LICENSE.md)
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
"use strict";
|
||||
|
||||
const EventEmitter = require('events');
|
||||
const pcsclite = require('bindings')('pcsclite');
|
||||
|
||||
// pcsclite.node is a Node.js native C++ addon that is compiled during installation
|
||||
// via node-gyp (see package.json > scripts > install)
|
||||
// the build output name and directory is constant so we can require it directly
|
||||
// see https://github.com/nodejs/node-gyp/issues/263, https://github.com/nodejs/node-gyp/issues/631
|
||||
const pcsclite = require('../build/Release/pcsclite.node');
|
||||
|
||||
const { PCSCLite, CardReader } = pcsclite;
|
||||
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
"test": "mocha --exit"
|
||||
},
|
||||
"dependencies": {
|
||||
"bindings": "^1.5.0",
|
||||
"nan": "^2.14.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
12
yarn.lock
12
yarn.lock
@@ -86,13 +86,6 @@ binary-extensions@^2.0.0:
|
||||
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.0.0.tgz#23c0df14f6a88077f5f986c0d167ec03c3d5537c"
|
||||
integrity sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow==
|
||||
|
||||
bindings@^1.5.0:
|
||||
version "1.5.0"
|
||||
resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.5.0.tgz#10353c9e945334bc0511a6d90b38fbc7c9c504df"
|
||||
integrity sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==
|
||||
dependencies:
|
||||
file-uri-to-path "1.0.0"
|
||||
|
||||
brace-expansion@^1.1.7:
|
||||
version "1.1.11"
|
||||
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
|
||||
@@ -238,11 +231,6 @@ esprima@^4.0.0:
|
||||
resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71"
|
||||
integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==
|
||||
|
||||
file-uri-to-path@1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd"
|
||||
integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==
|
||||
|
||||
fill-range@^7.0.1:
|
||||
version "7.0.1"
|
||||
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40"
|
||||
|
||||
Reference in New Issue
Block a user