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

electron issues #174

Closed
khrome opened this issue Dec 22, 2016 · 15 comments
Closed

electron issues #174

khrome opened this issue Dec 22, 2016 · 15 comments

Comments

@khrome
Copy link

khrome commented Dec 22, 2016

Hey there, I'm just trying to verify a library I write ( https://www.npmjs.com/package/barcode-scanner ) will work in electron, but deps are proving to be an issue.

Electron + HID installation attempts have been frustrating, I first tried all kinds of voodoo in my own project, but lost faith that it really had anything to do with that project (at very least I want to confirm node-hid would install in a vanilla project).

I then tried the node-hid-toy repo, which will not compile for me. Out of the box it complains rimraf is missing and then when I manually add that I wind up fatal on compile. I've tried using the install hook, and manually triggering

Is there something I'm missing?

https://gist.github.com/khrome/eb9721e6ffeb740e371db8822c252d1d

@todbot
Copy link
Contributor

todbot commented Dec 23, 2016

Hi @khrome,

A few questions to help us figure out what's going on:

  1. It looks like you're running Node v4.4.7 on Mac OS X 10.11.6. Is that correct?
  2. Do you have Xcode installed? If so, what version?
  3. What version of Electron are you trying to build node-hid for?
  4. Do you have node-gyp and node-pre-gyp globally? (or really, have you installed the prereqs in: https://github.com/node-hid/node-hid#compiling-from-source )

@khrome
Copy link
Author

khrome commented Dec 23, 2016

I was, but have updated to current with electron + nvm (1.4.13 & 6.5.0) at the 4th log. Before I was on (1.4.11 & 4.4.7). It seems like the compiler is either being given the wrong flags or is running with some strange or unexpected defaults. I am, indeed, on OSX 10.11.6. I have both node-gyp and node-pre-gyp installed globally and am running xcode 8.0 (8A218a).

Let me know if I can provide any other details!

@todbot
Copy link
Contributor

todbot commented Dec 23, 2016

Hi!
You might try upgrading your node and then uninstalling & re-installing globally node-gyp & node-pre-gyp. These are the tools responsible for actually doing compilation and they've been known to be finicky with versions of node & electron.

The fact that you're getting so many errors is indicative that something very essential is not getting set up correctly. Both before and after doing the node upgrades mentioned above, what is output with the following commands:

which gcc
which make
which node
which node-gyp
which node-pre-gyp

Also, in a different directory, try building node-hid all by itself, by doing:

git clone https://github.com/node-hid/node-hid.git
cd node-hid                                        # must change into node-hid directory
git submodule update --init                        # done on publish automatically
npm install                                        # rebuilds the module
node-pre-gyp rebuild                               # rebuilds the C code

@khrome
Copy link
Author

khrome commented Dec 23, 2016

~/NPMs/electron-hid-toy:daedalus>which gcc
/usr/bin/gcc
~/NPMs/electron-hid-toy:daedalus>which make
/usr/bin/make
~/NPMs/electron-hid-toy:daedalus>which node
/Users/khrome/.nvm/versions/node/v6.5.0/bin/node
~/NPMs/electron-hid-toy:daedalus>which node-gyp
/Users/khrome/.nvm/versions/node/v6.5.0/bin/node-gyp
~/NPMs/electron-hid-toy:daedalus>which node-pre-gyp
/Users/khrome/.nvm/versions/node/v6.5.0/bin/node-pre-gyp

I got the same output (added to the gist) from a direct clone & install of node-hid

Thanks!

@todbot
Copy link
Contributor

todbot commented Dec 23, 2016

Dang that's weird in that it's prefectly normal. I'm on the same OS with the same version of node and node-hid compiles fine. Hmm, I'll keep looking around for other clues. Is your system configured interestingly in any way?
Oh, a few other things you can try for more info:

gcc --version
pwd         

The pwd is in the directory of your node-hid checkout, just to let me know if there are any weird characters in your path. Some have reported issues with spaces or whatnot when using node-gyp.

@khrome
Copy link
Author

khrome commented Dec 23, 2016

gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.0.0 (clang-800.0.38)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

pwd /Users/khrome/NPMs/node-hid

@khrome
Copy link
Author

khrome commented Dec 28, 2016

Over the holidays I tried upgrading to Sierra, which had no effect. Continuing to investigate...

@khrome
Copy link
Author

khrome commented Jan 10, 2017

Good news, I finally got electron-hid-toy working (sort of), unfortunately I cannot tell you where the issue arose (other than something was wrong with gcc). After doing a clean install of Sierra, everything is compiling normally, though the script output is unexpected. After compiling I get /build/{module_name}/{configuration}/HID.node instead of /build/HID/Release/HID.node... if I correct this, everything works normally.

I'll close this after I validate it in the parent project I was originally working on.

Thanks for the attention.

@khrome
Copy link
Author

khrome commented Jan 11, 2017

OK, I can confirm everything except the compile path is working under an electron (under node the compile path seems fine) project and everything is working (as expected) in node.js proper.

Feel free to let this issue dangle for the /build/{module_name}/{configuration}/HID.node build issue or close this and open a new one... for now It's a wart I can live with.

@danielmcq
Copy link

I have this issue, too. I noticed that in the package.json file under the "binary" section, it looks like this:

  "binary": {
      "module_name": "HID",
      "module_path": "./build/{module_name}/{configuration}/",
      "host": "https://github.com/node-hid/node-hid/releases/download/",
      "remote_path": "{version}"
  },

I have an electron app which depends on node-hid, and when I run it I get an error about node_modules/node-hid/build/HID/Release/HID.node not being found. When i change the module_path in package.json to ./build/HID/Release/, my electron app starts up correctly. This may be a problem with npm because I'm assuming that {module_name} and {configuration} are supposed to replaced when the build script it ran. I don't know it hard-coding is the right way to resolve this issue, but it is one way to solve this problem without having to rename folders every time npm install is ran.

todbot added a commit that referenced this issue Jan 16, 2017
@todbot
Copy link
Contributor

todbot commented Jan 16, 2017

Hi @danielmcq & @khrome,
Thanks for your looking into this. I've spent the last few days looking into this again and re-examining how I thought node-gyp and node-pre-gyp behave. I think I discovered a fix to the configuration that addresses the issues you're seeing. I'm still testing the different platforms and environments but I'm hopeful. If you've been working from a checkout of node-hid and want to try it out, try pulling down the changes and see if they work for you.

@danielmcq
Copy link

Thanks!
Yeah, I'll point my electron project to the repo and try a clean install. I'll report back with the results.

@danielmcq
Copy link

danielmcq commented Jan 16, 2017

@todbot The latest code in master seems to have fixed the issue. Thank you for working on that. I'm still not experience with everything involved with node-gyp otherwise I would have tried doing a pull request for you. BTW, will you be bumping either the minor or patch version of node-hid now that you have this code in place?

EDIT: I see that the patch version got bumped right after the change that fixed this. Ignore my question in this post. Thanks again!

@todbot
Copy link
Contributor

todbot commented Jan 16, 2017

Cheers, @danielmcq. Thanks for testing things out.

@khrome
Copy link
Author

khrome commented Jan 16, 2017

Thanks! @todbot, @danielmcq

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

No branches or pull requests

3 participants