Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to start using Electron 4 and npm on Windows #60

Closed
madsbrydegaard opened this issue Dec 27, 2018 · 7 comments
Closed

Fails to start using Electron 4 and npm on Windows #60

madsbrydegaard opened this issue Dec 27, 2018 · 7 comments
Assignees
Labels

Comments

@madsbrydegaard
Copy link

When starting demo using NPM and electron start script nfc-pcsc fails. Starting using only node everything works perfectly.

From log:
10 silly lifecycle [email protected]start: Args: [ '/d /s /c', 'electron .' ]
11 silly lifecycle [email protected]
start: Returned: code: 3228369023 signal: null
12 info lifecycle [email protected]~start: Failed to exec start script
13 verbose stack Error: [email protected] start: electron .
13 verbose stack Exit status 3228369023
13 verbose stack at EventEmitter. (C:\Users\mads\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack at EventEmitter.emit (events.js:182:13)
13 verbose stack at ChildProcess. (C:\Users\mads\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:182:13)
13 verbose stack at maybeClose (internal/child_process.js:962:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
14 verbose pkgid [email protected]
15 verbose cwd C:\Users\mads\Source\Repos\Re5.com\Electron.CardLoader
16 verbose Windows_NT 10.0.17134
17 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Users\mads\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "start"
18 verbose node v10.14.2
19 verbose npm v6.5.0
20 error code ELIFECYCLE
21 error errno 3228369023
22 error [email protected] start: electron .
22 error Exit status 3228369023
23 error Failed at the [email protected] start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 3228369023, true ]

Additional info:
This happens for all libs using santigimeno/node-pcsclite

@pokusew
Copy link
Owner

pokusew commented Dec 28, 2018

Hi @madsbrydegaard,

Node.js 10.x (the one Electron uses now) and 11.x were not supported due to outdated bindings to Node Native modules API.

I upgraded all the dependencies (especially @pokusew/pcsclite) and also made a lot of fixes. Support for all recent Node.js versions along with many improvements is available in v0.7.0. 🚀

Please upgrade nfc-pcsc in your dependencies and let me know if it works for you. 🙂

Hope it helps. 🙂


PS Don't forget to star ⭐️my library, if you find it useful. 😃Thanks.

@pokusew pokusew self-assigned this Dec 28, 2018
@madsbrydegaard
Copy link
Author

Hi @pokusew
Thanks for the quick reply and new update.
However it doesnt seem to fix the problem. I am still getting the same error...

I updated the dependency, nuked the modules cache, npm rebuild, electron rebuild and then npm start...

packages.json:

{
  "name": "electron.card-loader",
  "version": "0.0.1",
  "description": "Electron.CardLoader",
  "main": "nfc-pcsc.js",
  "scripts": {
    "start": "electron ."
  },
  "author": {
    "name": ""
  },
  "dependencies": {},
  "devDependencies": {
    "electron": "^4.0.0",
    "electron-rebuild": "^1.8.2",
    "nfc-pcsc": "0.7.0"
  }
}

But unfortunately still the same error as above...
I am however new to electron so maybe I am missing something?

Any help is greatly appreciated.
Thnx

@pokusew
Copy link
Owner

pokusew commented Dec 31, 2018

Hi @madsbrydegaard,

Please try the following:

  1. Ensure the the NFC reader is connected to the computer, before starting the app
  2. Start the app
  3. If it works – then it is the known Windows issue, which in some cases prevents the nfc-pcsc to work correctly when the reader is not connected.
  4. It it does not work – I think something in your setup is not configured correctly. Please create a repo on GitHub, push your code and send me a link here and I'll look into it.

Hope it helps. 🙂

@madsbrydegaard
Copy link
Author

Hi @pokusew
I have now tested again and it still fails using electron.

Link to repo: https://github.com/madsbrydegaard/electron-pcsc

However using node runtime instead of electron it works very well.
Any help is greatly appreciated ;)

Thnx

@pokusew
Copy link
Owner

pokusew commented Jan 3, 2019

Hi @madsbrydegaard,

I cloned the repo and successfully started the app.

I think, that your problem is incorrect electron-rebuild usage.

The correct flow is:

  1. install the dependencies
  2. rebuild native modules you want to run inside Electron (i.e. in your case just nfc-pcsc) with the following command: electron-rebuild -f -w nfc-pcsc
  3. run the app
  4. rebuild native modules with the command above whenever you install/upgrade/uninstall any modules

The best practice is to have electron-rebuild installed as devDependency of your project and then add the rebuild script to the scripts section of the package.json.

I made all the changes (and a few more) and created a PR madsbrydegaard/electron-pcsc#1 in your repo. 🚀

Please do the following:

  1. Merge it in GitHub
  2. Pull the changes using git pull
  3. Delete node_modules
  4. Install dependencies with npm install
  5. Rebuild the dependencies with npm run rebuild (Don't forget the run word!)
  6. Run the app with npm start

Please let me know if it works for you.

Hope it helps. 🙂


PS Don't forget to star ⭐️my library, if you find it useful. 😃Thanks.

@madsbrydegaard
Copy link
Author

@pokusew - that solved the problem. Thnx a lot!
I think that I previously failed to compile nfc-pcsc correctly for electron but following your steps did the trick.
Also my cardreader and card shows up (and down) as expected.

However I get an error when reading card data - I might get back on that in another tread.

Your the man ;)
Thnx again

@pokusew
Copy link
Owner

pokusew commented Jan 6, 2019

@madsbrydegaard That's great! 👍I am closing the issue now.

Feel free to open another one if you encounter any issues while reading/writing card data. 😉

Also be sure to check out the nfc-pcsc examples, where you can find many useful info on reading and writing card data. 🙂

@pokusew pokusew closed this as completed Jan 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants