justinlatimer / node-midi

A node.js wrapper for RtMidi providing MIDI I/O
MIT License
745 stars 119 forks source link

Problem with nan - AccessorSignature #230

Open RichardFoss opened 2 years ago

RichardFoss commented 2 years ago

I have been using this package very successfully for a few years, thank you! Recently I updated to node v 18.10.0 and nw v0.69.1. When I rebuild: nw-gyp rebuild --target=0.69.1 --arch=x64 I get: ../../nan/nan_callbacks.h:55:23: error: no member named 'AccessorSignature' in namespace 'v8' typedef v8::Local Sig;


And so the build fails. I have tried putting this into the midi package.json:
"overrides": {
    "nan": "github:jkleinsc/nan#remove_accessor_signature"
  },
But still get the same message. Any suggestions?
Julusian commented 2 years ago

Do you fancy giving https://www.npmjs.com/package/@julusian/midi a try? Its a api compatible rewrite on node-api https://github.com/justinlatimer/node-midi/pull/228. I don't know if it will work with nw (I've never used nw myself), but Im happy to get it working if it is wanted

RichardFoss commented 2 years ago

Thank you very much! I will try it and let you know how it goes. I am using both Mac and PC.

RichardFoss commented 2 years ago

I'm getting this error message when I use the module. I'm not clear on the binding mechanism. If you have an immediate solution, that would be great, otherwise I will study binding! I'm testing on a Mac.

Uncaught Error: Failed to find binding for midi
    at loadBinding (/Users/csrf/Documents/Git-Repos/ImmerGo-Presonus-SL/immergo-presonus-sl/node_modules/pkg-prebuilds/bindings.js:91:27)
    at Object.<anonymous> (/Users/csrf/Documents/Git-Repos/ImmerGo-Presonus-SL/immergo-presonus-sl/node_modules/@julusian/midi/midi.js:1:47)
    at Module._compile (node:internal/modules/cjs/loader:1173:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1233:10)
    at Module.load (node:internal/modules/cjs/loader:1051:32)
    at Module._load (node:internal/modules/cjs/loader:892:12)
    at Module.require (node:internal/modules/cjs/loader:1075:19)
    at require (node:internal/modules/cjs/helpers:98:18)
    at self.require (<anonymous>:11:26)
    at self.require (<anonymous>:11:26)
Julusian commented 2 years ago

The binding is the native component, which you were having issues building at the start of this issue thread.

Oh, and I can immediately see the issue, its looking for a nw version of the file (separate to the node/electron version), which I havent prebuilt.. Have you tried that nw-gyp rebuild --target=0.69.1 --arch=x64 to see if it helps?

RichardFoss commented 2 years ago

Apologies for the slow reply - had to leave this for a while. I have done the rebuild and it works! Thank you VERY much for your module and for all your help! I can get MIDI input and output ports and display them. I still need to test transmission and receipt of messages. It's a bit late here now - I will test over the weekend and let you know how it goes. Thanks again!

Julusian commented 2 years ago

I've spent a couple of hours looking into what I can do on this and I am not sure how best to proceed

It looks like it would be possible to automate making prebuilt binaries for nwjs, but for windows that does require modifying a file from node-gyp which sounds like it is going to be very fragile and fiddly. If this works, I expect this could be done as one binary used by all of node, electron and nwjs.

Or perhaps nwjs is a small enough user base to not worry about it for now, and leave it as expected that you will need to run nw-gyp rebuild --target=0.69.1 --arch=x64

I have opened an issue to discuss whether that file hack is necessary or if it could be upstreamed, which would be the ideal solution but will take time to happen if it ever does.

RichardFoss commented 2 years ago

Thanks for all the work on this issue! From my point of view, doing the rebuild is fine. Just need to document it, so I remember :)