node-irsdk icon indicating copy to clipboard operation
node-irsdk copied to clipboard

Electron support?

Open apihlaja opened this issue 6 years ago • 40 comments

package.json has only node.js version defined at the moment. But Electron binaries are available too. Should figure out which versions of Electron actually work.

apihlaja avatar Dec 03 '17 15:12 apihlaja

Im trying to make a node-irsdk + electron app happen, but im getting compatabilty issues. Is there a version of electron known to be working?

Dahara2012 avatar May 26 '19 18:05 Dahara2012

I made it work with electron 1.8.5

Dahara2012 avatar May 26 '19 20:05 Dahara2012

The latest release had electron binary for v57 ABI. node-abi suggests it should be compatible with electron 1.8.0 and 2.0.0.

But that's just prebuild binaries. Node.js binary is for v64 ABI so at least Electron 3.0.0 should work if you compile it yourself. There is guide for installing node.js build tools on windows: https://github.com/nodejs/node-gyp#on-windows

It seems there is some issue at the moment since builds have been failing last month: https://ci.appveyor.com/project/apihlaja/node-irsdk/history

I guess issue is some outdated dependencies, ie. prebuild-install or nan. I'll go thru open PRs to see if those fix the issue..

apihlaja avatar May 31 '19 08:05 apihlaja

Ok, now there is a new release of node-irsdk with latest prebuild binaries: https://github.com/apihlaja/node-irsdk/releases

  • the latest electron binary is for v69 ABI. It should be compatible with electron v4.0.4 and later but no v5
  • the latest node.js binary is for v67 ABI which is used by Node.js v11

Let me know if you have compatabilty issues with newer versions still.

apihlaja avatar May 31 '19 09:05 apihlaja

Hi guys, I'm currently having a similar issue trying to get the package to work with an electron app.

After installing node-irsdk I get the error:

This relative module was not found:

  • ../build/Release/IrSdkNodeBindings in ./node_modules/node-irsdk/src/node-irsdk.js

I checked in explorer to see if the file is missing but its there. I also ran electron-rebuild (rebuild command for native modules, is this even native?) without any success.

My project currently runs electron version 4.1.5, an older project which runs 2.0.17 is working fine. Is there anything I can do to make it run?

Thx for any help 👍

sabifa avatar Jun 02 '19 11:06 sabifa

Sorry, maybe dumb question, how to use these binary relases (IrSdkNodeBindings.node from node-irsdk-v2.1.5-electron-v69-win32-x64)?

I'm new to node / electron, tried: const addon = require('../../../../irsdk/IrSdkNodeBindings.node');

but got:

ERROR in ./irsdk/IrSdkNodeBindings.node 1:2
Module parse failed: Unexpected character '�' (1:2)
You may need an appropriate loader to handle this file type.
(Source code omitted for this binary file)

Not surprisingly npm install --save node-irsdk didnt work.

Im working with: https://github.com/maximegris/angular-electron in branch angular7 which is using: "electron": "4.0.0", (see: https://github.com/maximegris/angular-electron/blob/angular7/package.json)

sushi86 avatar Jun 20 '19 19:06 sushi86

You shouldn't be requiring that file yourself, that's handled by lib itself. For some reason, that doesn't work.

I'll take a look when I have time (next week maybe). It seems there is some things to catch up for me. This extension has worked since node.js v0.12 days without much work but it seems now there has been some changes. I'm not mainaining anything else related to node.js native addons so I'm a bit out of loop.

Earlier, I used bindings-module. I dont remember why I dropped it. That might be the first thing to try.

apihlaja avatar Jun 20 '19 19:06 apihlaja

Thanks a lot for this fast answer <3 I will take a look. Would be really nice if you find the time for fixing that. But I can understand that other things have higher priority.

sushi86 avatar Jun 20 '19 19:06 sushi86

Finally, I managed to update nan and update binaries for node.js v12. I didnt test Electron yet but at least new version compiles now.

apihlaja avatar Jul 02 '19 16:07 apihlaja

Thx for the update Antti!

Unfortunately it still doesn't work for me no matter if I use electron or not. Still getting the same error:

This relative module was not found:
../build/Release/IrSdkNodeBindings in ./node_modules/node-irsdk/src/node-irsdk.js

sabifa avatar Jul 03 '19 05:07 sabifa

Just did some testing again and the error tells me that it somehow doesnt find the created .node file which is getting imported at line 1.

I cloned your repo and ran the commands npm run ready and npm run prebuild which both ran without any errors.

I also created a .js file (containing node-irsdk relevant code) which I ran with node index.js and it executed fine without any problems. Do you have any clue on where this problem could be located?

sabifa avatar Jul 07 '19 10:07 sabifa

I was about to look it myself too finally today. I don't really have any idea what's causing the issue. I'll probably just try to use bindings-module again. I dropped that at some point because it looked like unnecessary dep. I didn't find any PRs or issues from it related to v12 or new Elecron so maybe it simply works 😅

apihlaja avatar Jul 07 '19 11:07 apihlaja

Hmm.. I can't replicate the issue using Node.js v12

$ nvm install 12.6.0
$ nvm use 12.6.0

Attempt 1:

$ git clone [email protected]:apihlaja/node-irsdk.git
$ cd node-irsdk 
$ npm install
$ node

And in Node.js REPL

> const iracing = require('.').getInstance()
> iracing.telemetry

Attempt 2:

$ mkdir iracing-test && cd iracing-test && npm init -y
$ npm install node-irsdk
$ node

And then in REPL:

> const iracing = require('node-irsdk').getInstance()
> iracing.telemetry

And doing same in index.js works too so that's not a factor.

apihlaja avatar Jul 07 '19 12:07 apihlaja

I can run it fine if I use node to start the script as well but not if I want to use it in my vue.js project (error is not vue related I tried other frameworks as well)

https://github.com/sabifa/node-irsdk-vue Clone this install all dependencies and try to run it with the command npm run serve to reproduce the issue.

sabifa avatar Jul 07 '19 12:07 sabifa

Isn't that purely browser-side code? That's not going to work: node-irsdk has to be running inside Node.js or Electron. With Node.js, it means you need some kind of http or websocket-server. With Electron, you can do same or use some of alternatives that Electron has.

There is heavily outdated example of how to do it with Node.js using Socket.io: https://github.com/apihlaja/node-irsdk-inspector

apihlaja avatar Jul 07 '19 12:07 apihlaja

I thought its good to try it without electron to determine if it's electron which is causing the issue. Nevertheless it also doesn't work with electron 😢

Clone this and try to install node-irsdk and use it - I'm getting the same error. (Electron + Vue.js + node-irsdk has worked a couple of months ago)

sabifa avatar Jul 07 '19 12:07 sabifa

Electron-Vue-Boilerplate seems to be very tiny wrapper which runs normal browser app in Electron. You should have access to node-irsdk at least in backgroud.js but it looks like that's not even used in dev mode of the boilerplate.

apihlaja avatar Jul 07 '19 13:07 apihlaja

Oh my god, of course!

This is the reason because it worked in the past. I used another way to initialize the electron project, namely this. It uses node to start the electron app and oh wonder it just works!

Sorry for taking your time.. 😅 It is working now 👍

sabifa avatar Jul 07 '19 13:07 sabifa

I tried to create a quick start based on the default electron quick start but I found this issue: https://github.com/prebuild/prebuild/issues/249

Ie. currently my prebuild binaries for Electron v5 binaries are actually for Node.js v5. That was causing some head scratching. I subbed the issue, I'll try to complete quick start when I have actually working binary easily available.

I guess electron-vue gets around that issues somehow by forcing rebuild.

apihlaja avatar Jul 07 '19 14:07 apihlaja

Not sure if thats related but I had to use electron-rebuild, after rebuilding it worked fine.

sabifa avatar Jul 07 '19 14:07 sabifa

electron-rebuild doesn't seem to do anything, no matter what flags I give for it. It just happily says "Build Complete" without actually doing anything.

apihlaja avatar Jul 07 '19 14:07 apihlaja

Any progress with this. I'm currently able to use node-irsdk with Electron 4.x and NodeJS 12 if I run electron-rebuild. Would be nice if it worked with 5.x

This is the error I get with Electron 5

Uncaught Error: The module '\\?\D:\src\node\iracing\node_modules\node-irsdk\build\Release\IrSdkNodeBindings.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 47. This version of Node.js requires
NODE_MODULE_VERSION 70. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at process.func [as dlopen] (electron/js2c/asar.js:155)
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:881)
    at Object.func [as .node] (electron/js2c/asar.js:155)
    at Module.load (internal/modules/cjs/loader.js:701)
    at tryModuleLoad (internal/modules/cjs/loader.js:633)
    at Function.Module._load (internal/modules/cjs/loader.js:625)
    at Module.require (internal/modules/cjs/loader.js:739)
    at require (internal/modules/cjs/helpers.js:14)
    at Object.<anonymous> (D:\src\node\iracing\node_modules\node-irsdk\src\node-irsdk.js:1)
    at Object.<anonymous> (D:\src\node\iracing\node_modules\node-irsdk\src\node-irsdk.js:49)

skaughtx0r avatar Jul 26 '19 22:07 skaughtx0r

I think @sabifa confirmed it works with v5 now? The issue is that prebuilt binary is wrong, as described in that prebuild-issue. Ie. if you want to use v5, you have to compile it yourself: https://electronjs.org/docs/tutorial/using-native-node-modules

You probably has to somehow force rebuilding because provided binary doesnt work. npm_config_build_from_source parameter might do the trick.

apihlaja avatar Jul 27 '19 08:07 apihlaja

I can't confirm it right now as I'm on vacation but I think I didn't try electron v5 yet. Will do that when I'm back home and report back.

sabifa avatar Jul 27 '19 09:07 sabifa

if this is of any help, i tried to get it to work on electron v6.0.1 together with electron-rebuild and so far it works just fine. You do have to manually rebuild using electron-rebuild. this is the boilerplate i used: https://github.com/electron/electron-quick-start

mike1233 avatar Aug 08 '19 19:08 mike1233

@mike1233 can you please provide some help with this? I checked out this quick start, run electron rebuild and tried to install node-irsdk, but still getting my old error message ("prebuild-install" not installed, and some python errors)

Would be really nice!

sushi86 avatar Oct 14 '19 15:10 sushi86

I've successfully rebuilt it for Electron ^6.1. Could not make it work for Electron v7 tho. All I did was this:

npm install --global --production windows-build-tools npm install --save-dev electron-rebuild

and

.\node_modules\.bin\electron-rebuild.cmd

raicem avatar Oct 29 '19 19:10 raicem

can we have this fixed for electron 7? Also why a node package has any electron references?

iamisti avatar Nov 18 '19 12:11 iamisti

So I tried it again today and I am also able to rebuild the package for Electron 6.1.5, Electron 7.x gives me an error.

Make sure to run the rebuild command already mentioned by @raicem

sabifa avatar Dec 22 '19 14:12 sabifa

Any news on that issue? Does it work again or is the prebuild still failing?

martinguder avatar Apr 01 '20 17:04 martinguder