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

Tracking Electron support #538

Closed
a-giovani17 opened this issue Jun 4, 2015 · 122 comments
Closed

Tracking Electron support #538

a-giovani17 opened this issue Jun 4, 2015 · 122 comments

Comments

@a-giovani17
Copy link

I have an Electron desktop app that requires some nodejs packages including serialport. But only serialport is failed to require.

I included it like this:

var SerialPort = require('serialport').SerialPort;
var sp = require('serialport');

But when I run it on Electron, it shows following error:

Error: Cannot find module 'C:\xampp\htdocs\simplemail-desktop\node_modules\serialport\build\serialport\v1.7.4\Release\node-v43-win32-ia32\serialport.node'

I've check that the folder actually doesn't exists. When I installed serialport, it created folder 'node-v14-win32-ia32' instead of 'node-v43-win32-ia32'. Maybe there is something wrong in the installation process. What should I do?

@bongia
Copy link

bongia commented Jun 4, 2015

Same here

@voodootikigod
Copy link
Collaborator

I just got my electron today will investigate!

what version of node are you using?

Chris Williams

@voodootikigod http://twitter.com/voodootikigod | GitHub
http://github.com/voodootikigod

The things I make that you should check out:
SaferAging http://www.saferaging.com/ | JSConf http://jsconf.com/ |
RobotsConf http://robotsconf.com/ | RobotsWeekly
http://robotsweekly.com/

Help me end the negativity on the internet, share this
http://jsconf.eu/2011/an_end_to_negativity.html.

On Thu, Jun 4, 2015 at 11:05 AM, Gianluca Bonacin notifications@github.com
wrote:

Same here


Reply to this email directly or view it on GitHub
#538 (comment)
.

@bongia
Copy link

bongia commented Jun 4, 2015

  • Node version: 0.12.4
  • Electron version: 0.27.2

The code is simply a boilerplate:

var app = require("app");
var BrowserWindow = require("browser-window");
var mainWindow = null;

app.on("window-all-closed", function () {
  if (process.platform !== "darwin") {
    app.quit();
  }
});

app.on("ready", function () {
  mainWindow = new BrowserWindow({
    width: 960,
    height: 600
  });
  mainWindow.loadUrl("file://" + __dirname + "/index.html");
  mainWindow.on("closed", function () {
    mainWindow = null;
  });

  mainWindow.openDevTools();


  var SerialPort = require("serialport").SerialPort;
  var serialPort = new SerialPort("TODO-TODO-EL-MEXICO!", {
    baudrate: 57600
  });

});

@landuomu
Copy link

landuomu commented Jun 9, 2015

Same here

I am using Ubuntu 14.04 LTS. I got this when I require serialport when i run in electron.

[3512:0609/164117:INFO:CONSOLE(326)] "Uncaught Error: Cannot find module './node_modules/serialport/build/serialport/v1.4.10/Release/node-v43-linux-x64/serialport.node'", source: module.js (326)

I didn't found this folder but I found './node_modules/serialport/build/serialport/v1.4.10/Release/node-v11-linux-x64/serialport.node'

Node version: 0.10.25
Electron version: 0.27.2

@a-giovani17
Copy link
Author

Actually when I renamed the folder to ''node-v43-win32-ia32', this error shown:

Uncaught Exception:
Error: Invalid Access to Memory Location

maybe there is something wrong in the native module (serialport.node)

@landuomu
Copy link

landuomu commented Jun 9, 2015

I rename the folder too, and I get this:

[3827:0609/165900:INFO:CONSOLE(134)] "Uncaught Error: Module did not self-register.", source: ATOM_SHELL_ASAR.js (134)

@uropsm
Copy link

uropsm commented Jun 17, 2015

I have same issue.

When I installed serialport, it created folder 'node-v14-win32-x64' instead of 'node-v43-win32-ia32

Windows7 64bit
node version : 0.12.4

@kjlaw89
Copy link

kjlaw89 commented Jun 24, 2015

Hey guys, apparently @usefulthink was able to get this to work by just changing how node-serialport built. I'm using it in my Electron setup right now and it's working well. Here's the link to the commit/fork:

usefulthink@c5aace8

@a-giovani17
Copy link
Author

I've tried @usefulthink's commit, the folder problem is solved but my electron app still show this error:

Uncaught Exception:
Error: Invalid Access to Memory Location

The error comes from the binary (serialport.node), I wonder why.
Maybe this is because I use Microsoft Visual Studio 2012. If that's true, which version should I use?

@usefulthink
Copy link

I didn't really test anywhere except for OSX 10.10 which was all that I needed. But as all I did was replacing node-pre-gyp with node-gyp that is from my understanding unlikely to be the problem.

Unfortunately, its several years since I last worked with Windows, so no idea..

@usefulthink
Copy link

I couldn't find anything about it here, but that might cause such a problem - did you use electron-rebuild to recompile the add-on?

@a-giovani17
Copy link
Author

yes, I've used electron-rebuild but the error still appeared

@voodootikigod
Copy link
Collaborator

Hey All, so the @usefulthink fork actually provided me with the insight into what is going with this and I would like to share it so everyone can understand it.

Originally, node-serialport (this module) used a project called node-gyp directly to provide the instructions for compiling the module on various platforms (Windows, Mac, Linux, etc.). While it worked (assuming all necessary dependencies) it was a nightmare as for doing any form of mass installation because undoubtably the necessary dependencies (build tools, compiler, etc) were never installed. This project, node-serialport, quickly became swamped with tickets about how to install on Windows, Mac, and Linux.

Due to this, we moved to using a project called node-pre-gyp, which allowed us to utilize pre-compiled binaries if they exist from a known location and fallback to the local build process if they do not. This was hooked into an elaborate build system using Travis-CI and AppVeyor to generate the necessary compiled versions for Windows, Mac, and Linux on each release published to npm.

Things were happy at this point since people using Windows, Mac, and Linux without the build components could easily use node-serialport without even being aware of its native module nature.

During this time period, the project formerly named node-webkit, now nw.js, started to evolve and gain traction. It utilized its own derivative fork/hack from node-gyp in order to build the necessary native componets which was named nw-gyp and this choice had ramifications that affected the compilation of other native modules. Needless to say, as people began trying to use it in combination with the node-serialport project things did not work smoothly. Until the NW.js team published the previously linked instructions for node-gyp and node-pre-gyp, this project was blamed for incompatibility and many issues were filed.

Then the Atom editor was released. The Electron team that maintains the application framework around the Atom Editor updated to the latest version of Chromium around September, 2014, which consequentially broke compatibility with any and all node-gyp compiled modules. Similar to NW.js, the Electron team posted details about how build Electron with other native modules, but those native modules mostly were not aware of this. As such, many issues were filed against this and other project concerned about the compatibility of that project when they try to integrate with Electron.

The general node.js leadership has not openly discussed this mainly because they do not maintain end-user facing native modules, honestly there aren't a tremendous number of them. For those of us that do maintain a native module, the constant hamster wheel is enough to drive one insane. Until a maintainer can explore the other project, there is a very real sense that it could be the fault/issue/incompatibility of the project being maintained since Node.js, io.js and the ecosystem changes so quickly and its too much to keep up with. At this point, here is the general state of the world:

  • node-gyp is the de-facto build standard for Node.js and native modules. All things should be compatible with node-gyp at a minimum or else it should be considered out of compliance.
  • node-pre-gyp since it is an enhancement beyond node-gyp by adding pre-compilation and retrieval, it should be considered as part of the compliance suite for any native module.
  • nw-gyp to my knowledge is only used by NW.js and as such should ensure that it or application that includes does not break compliance with node-gyp or node-pre-gyp. That is currently not the case however and inclusion of node-gyp and node-pre-gyp modules still require special handling.
  • Atom-Shell/Electron is currently not compliant with node-pre-gyp due to the way that it identifies its node execution version and environment. That said, the node-pre-gyp maintainers are working on a way to make node-pre-gyp modules work with Electron. There is currently an outstanding pull request that will provide support for this variation handling. Until that pull request is merged in, continue to use the instructions provided by the Electron team.

Specifically for node-serialport, as the prime maintainer I will not be merging in modifications that take this project backwards (ala reverting to node-gyp). Also, I will not be integrating special cases to support new native environments that have broken compatibility without thorough testing in every execution environment we already support.

In summary, maintaining a native module in node.js is a constant battle. The node community needs to hold projects that break native compilation compatibility accountable by encouraging those projects to ensure node-gyp and node-pre-gyp modules can still be included without issue or failure.

@usefulthink
Copy link

Thank you so much for writing this! Fully agree.

@kjlaw89
Copy link

kjlaw89 commented Jun 25, 2015

@voodootikigod I agree too, I think it makes sense for node-pre-gyp to resolve the issue on their side rather than you changing your project. In the meantime the work @usefulthink should get us by.

@usefulthink @a-giovani17 Windows compiling does work, as that's where I'm doing my build. I'm using the 2013 compiler "--msvs_version=2013", with electron-rebuild for compiling running the command ".\node_modules.bin\electron-rebuild . --version=0.28.3". That downloads the 0.28.3 headers for electron and compiles against them.

Granted, I've done a lot of other things to my setup environment. If you wiped my computer and told me to get it all working again at this point I would likely be doomed. :P

@voodootikigod
Copy link
Collaborator

@usefulthink just want to make sure the 'going backwards' is not a knock on you by any means (I like your solution in the short run 👍). Cheers!

@usefulthink
Copy link

@voodootikigod no worries, I just needed it to work and did the ugliest hack I could think of. I wouldn't have thought of making a PR of it anyway, and I agree with you that this would indeed be moving backwards for this project :)

@0x80
Copy link

0x80 commented Jul 4, 2015

I am struggeling a bit to find out what the compatible Electron prebuilt version is and I suspect it is related to this issue. Are you using 0.27.2 because that is the last compatible version (uses iojs v1)? Or is serialport or the @usefulthink his fork also compatible with iojs v2 and Electron > 0.27?

I have tested serialport with iojs-v2 (without electron) and that seemed to work just fine, but somehow in combination with electron I haven't managed to make it work with versions > 0.27

Also running .\node_modules\.bin\electron-rebuild doesn't seem to do much. Is that command supposed to finish in a split second?

@usefulthink
Copy link

Hi @0x80, you should be able to install my forked-version with npm install serialport-electron, then electron-rebuild --force should do the trick (i don't really know how electron-rebuild determines what to rebuild, but you will see the usual compiler-output when it does). This should work in every node/iojs-version that is supported by this module, as it will always rebuild from source.
I guess you just have to try it.

@0x80
Copy link

0x80 commented Jul 5, 2015

@usefulthink thanks! I've managed to make it work with 0.29.1. Your module didn't seem to be available in npm registry so I installed if from git.

@0x80
Copy link

0x80 commented Jul 5, 2015

I'm still experiencing one major issue though. When I use serialport in combination with Electron, the CPU goes through the roof. The same code running on the same iojs version but as standalone only uses a very small percentage. The code does nothing but connect and read data coming from the port. I know the CPU load is not caused by things like logging or using the Electron IPC bus becuase I've cut out all overhead like that. I already mentioned it here #402. Any idea what might cause something like this? I realize this isn't really on topic but I am completely clueless.

@ddm
Copy link

ddm commented Jul 16, 2015

If anybody stumbles upon this while trying to use node-serialport with electron: there is a temporary solution in the form of the serialport-electron npm package.
Hopefully, in the long run, node-pre-gyp will support electron OOTB.

@alexgoldstone
Copy link

I believe this should help but have yet to confirm: mapbox/node-pre-gyp#175

@vjpr
Copy link

vjpr commented Oct 22, 2015

@ddm I get the following message when I try to require serialport-electron from main.js:

Uncaught Exception:
Error: Module version mismatch. Expected 46, got 44.
    at Error (native)
    at Object.module.(anonymous function) (ATOM_SHELL_ASAR.js:137:20)
    at Object.module.(anonymous function) [as .node] (ATOM_SHELL_ASAR.js:137:20)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/Users/Vaughan/xxx/node_modules/serialport-electron/serialport.js:12:25)
    at Module._compile (module.js:434:26)
    at Object.Module._extensions..js (module.js:452:10)

What version of node and electron are you using?

I am using iojs-v2.0.1.


Using npm install serialport gives me this error:

Uncaught Exception:
Error: Cannot find module '/Users/Vaughan/xxx/node_modules/serialport/build/serialport/v2.0.1/Release/node-v46-darwin-x64/serialport.node'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:286:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/Users/Vaughan/xxx/node_modules/serialport/serialport.js:14:25)
    at Module._compile (module.js:434:26)
    at Object.Module._extensions..js (module.js:452:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)

@ddm
Copy link

ddm commented Oct 22, 2015

@vjpr I just tested it with iojs-v2.0.1

It works for the following versions:

"serialport-electron": "1.7.4-electron-0.30.6",
"electron-prebuilt": "0.30.6"

I believe it should work with 0.30.8 without a change. Just let me know if you want me to publish "serialport-electron": "1.7.4-electron-0.30.8" to npm.

I think electron > 0.30.x requires a change to serialport to work properly because of a v8 version change.

@vjpr
Copy link

vjpr commented Oct 22, 2015

Thanks!

You are right, changing electron-prebuilt version to 0.30.6 worked on Windows.

The regular serialport worked on OSX.

@bhaveshgohel
Copy link

This is what i did to make it work:

  1. Install node-pre-gyp globaly:
npm install -g node-pre-gyp
  1. Add this to your package.json
"scripts": {
    "start": "electron .",
    "postinstall": "cd node_modules/serialport && node-pre-gyp rebuild --target=1.3.4 --arch=x64 --dist-url=https://atom.io/download/atom-shell",
    "rebuild:64": "cd node_modules/serialport && node-pre-gyp rebuild --target=1.3.4 --arch=x64 --dist-url=https://atom.io/download/atom-shell",
    "rebuild:32": "cd node_modules/serialport && node-pre-gyp rebuild --target=1.3.4 --arch=ia32 --dist-url=https://atom.io/download/atom-shell"
  }

Note: change --target= electron-version-you-use

  1. Install serialport
npm install -g serialport

By default it will install x64 version build of serialport as i set in postinstall script.

Now when you want to switch to 32bit build just fire below command.

npm run rebuild:32

Hope this helps someone. Good Luck. 👍

@fdeitelhoff
Copy link

I managed to get the serialport package working with Electron 1.4.12 on a Windows 10 x64 machine. Now I've the problem that the list function doesn't return anything:

var serialPort = require("serialport"); serialPort.list(function (err, ports) { console.log(err); console.log(ports); ports.forEach(function(port) { console.log(port.comName); console.log(port.pnpId); console.log(port.manufacturer); }); });

Did someone stumbled over the same issue? There are USB devices connect to my machine because I can see them in the USB Device Tree Viewer. They are connected to a generic USB hub (one of my displays).

@jacobq
Copy link
Contributor

jacobq commented Jan 19, 2017 via email

@fdeitelhoff
Copy link

Are the "USB devices" you speak of acting as COM ports? (Can you use a terminal program like putty to connect to it?)

Not sure, but it seems like I cannot connect via putty to it (it's a LEGO Mindstorms EV3).

@jacobq
Copy link
Contributor

jacobq commented Jan 19, 2017

@fdeitelhoff just glancing at your sample code I don't see any obvious problems. I suspect that your OS is not treating it as a serial port device. This could be driver/configuration related.
Have you tried seeing if it shows up in the output from the serialport-list command?

Note that I don't have and have never worked with this device, but based on a couple quick web searches it sounds like there are multiple interfaces for it (USB, Bluetooth, and WiFi). Though I can't be 100% certain, it looks like the USB interface acts as an HID (human input device) not a VCP (virtual com port) (see this .NET API for example). If that's the case, I would recommend trying the Bluetooth interface (once paired, your system should be able to see it as a serial/COM port) or Wi-Fi interface (not sure what the protocol is, but if it has the same capabilities then you could use the standard Node network API rather than relying on platform-specific extensions like node-serialport).

HTH

@Ciantic
Copy link

Ciantic commented Jan 19, 2017

I think this issue should be closed, right? This is not an issue, haven't been for a long time cause node-serialport works just fine with Electron.

The main problem is that of Electron, everyone who starts using Electron will have issues with native modules, and most issues in this thread is about getting native modules to work.

@reconbot
Copy link
Member

reconbot commented Jan 19, 2017 via email

@fdeitelhoff
Copy link

Many thanks to you all for your effort and patience. :)

As @jacobq stated, the EV3 is a HIDClass device. That's the reason it won't work with serialport. I tried the WIFI interface and this seems to be working fine. Bluetooth is the next test candidate.

@johnvs
Copy link

johnvs commented Mar 21, 2017

I was having a similar problem when using webpack. I learned the hard way that binary files need to be excluded from webpack. The solution was shockingly simple.

@ghost
Copy link

ghost commented Jul 17, 2017

Hi there, I'm still having issues with this, mainly because this discussion it's not clear at all. I'm on Win10 x64, running the latest versions of node and electron. I tried a few of the tips suggested here but it's still not working. Could you please suggest which of the previous methods IS currently (July 2017) working? Or eventually, if there's some clear docs around which goes straight to the point (if not I'd be happy to produce one after I manage to have it running on my end)?
Thank you.

@andrewjaykeller
Copy link

andrewjaykeller commented Jul 17, 2017 via email

@jacobq
Copy link
Contributor

jacobq commented Jul 17, 2017

@franz1900 I am using node-serialport in a project that uses ember-electron (which uses electron-forge under the hood) for building/packaging/releasing. It works very well. Without more context of what you're doing or what you want it's hard to give you advice. As @aj-ptw mentioned, if you could publish some code demonstrating where you're stuck that will make it easier for others to help. You might also want to check out the electron community on Slack.

@ghost
Copy link

ghost commented Jul 24, 2017

Hi there,
so I restarted everything from scratch. I'm following Cyantic post from Oct '16. I'm stuck at step 6:

npm install ffi --save-dev

where I get the following errors in npm-debug.log

1388 info build G:\ART\nodejs\ardu\node_modules\ffi\node_modules\debug
1389 info linkStuff debug@2.6.8
1390 silly linkStuff debug@2.6.8 has G:\ART\nodejs\ardu\node_modules\ffi\node_modules as its parent node_modules
1391 verbose linkBins debug@2.6.8
1392 verbose linkMans debug@2.6.8
1393 verbose rebuildBundles debug@2.6.8
1394 verbose rebuildBundles [ 'ms' ]
1395 info install debug@2.6.8
1396 info postinstall debug@2.6.8
1397 verbose unlock done using C:\Users\Fran\AppData\Roaming\npm-cache\_locks\debug-e6b5658bafc3ef9c.lock for G:\ART\nodejs\ardu\node_modules\ffi\node_modules\debug
1398 info ref@1.3.4 Failed to exec install script
1399 verbose unlock done using C:\Users\Fran\AppData\Roaming\npm-cache\_locks\ref-42c84230165c03fd.lock for G:\ART\nodejs\ardu\node_modules\ffi\node_modules\ref
1400 verbose about to build G:\ART\nodejs\ardu\node_modules\ffi
1401 verbose unlock done using C:\Users\Fran\AppData\Roaming\npm-cache\_locks\ffi-afc147decab49347.lock for G:\ART\nodejs\ardu\node_modules\ffi
1402 verbose stack Error: ref@1.3.4 install: `node-gyp rebuild`
1402 verbose stack Exit status 1
1402 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:217:16)
1402 verbose stack     at emitTwo (events.js:87:13)
1402 verbose stack     at EventEmitter.emit (events.js:172:7)
1402 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:24:14)
1402 verbose stack     at emitTwo (events.js:87:13)
1402 verbose stack     at ChildProcess.emit (events.js:172:7)
1402 verbose stack     at maybeClose (internal/child_process.js:827:16)
1402 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
1403 verbose pkgid ref@1.3.4
1404 verbose cwd G:\ART\nodejs\ardu
1405 error Windows_NT 10.0.15063
1406 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "ffi" "--save-dev"
1407 error node v4.4.7
1408 error npm  v2.15.8
1409 error code ELIFECYCLE
1410 error ref@1.3.4 install: `node-gyp rebuild`
1410 error Exit status 1
1411 error Failed at the ref@1.3.4 install script 'node-gyp rebuild'.
1411 error This is most likely a problem with the ref package,
1411 error not with npm itself.
1411 error Tell the author that this fails on your system:
1411 error     node-gyp rebuild
1411 error You can get information on how to open an issue for this project with:
1411 error     npm bugs ref
1411 error Or if that isn't available, you can get their info via:
1411 error
1411 error     npm owner ls ref
1411 error There is likely additional logging output above.
1412 verbose exit [ 1, true ]
1413 verbose unbuild node_modules\ffi\node_modules\ref
1414 info preuninstall ref@1.3.4
1415 info uninstall ref@1.3.4
1416 verbose unbuild rmStuff ref@1.3.4 from G:\ART\nodejs\ardu\node_modules
1417 verbose unbuild rmStuff in G:\ART\nodejs\ardu\node_modules\ffi\node_modules
1418 info postuninstall ref@1.3.4
1419 silly gentlyRm G:\ART\nodejs\ardu\node_modules\ffi\node_modules\ref is being purged from base G:\ART\nodejs\ardu
1420 verbose gentlyRm don't care about contents; nuking G:\ART\nodejs\ardu\node_modules\ffi\node_modules\ref
1421 silly vacuum-fs purging G:\ART\nodejs\ardu\node_modules\ffi\node_modules\ref
1422 silly vacuum-fs quitting because other entries in G:\ART\nodejs\ardu\node_modules\ffi\node_modules
1423 verbose unbuild node_modules\ffi
1424 info preuninstall ffi@2.2.0
1425 info uninstall ffi@2.2.0
1426 verbose unbuild rmStuff ffi@2.2.0 from G:\ART\nodejs\ardu\node_modules
1427 info postuninstall ffi@2.2.0
1428 silly gentlyRm G:\ART\nodejs\ardu\node_modules\ffi is being purged from base G:\ART\nodejs\ardu
1429 verbose gentlyRm don't care about contents; nuking G:\ART\nodejs\ardu\node_modules\ffi
1430 silly vacuum-fs purging G:\ART\nodejs\ardu\node_modules\ffi
1431 silly vacuum-fs quitting because other entries in G:\ART\nodejs\ardu\node_modules

I have python 2.7 and Visual Studio 2017 and I've just installed C++ tools. I've also un the following


npm config set msvs_version 2017 --global
npm config set python /Python27/python.exe --global

@reconbot
Copy link
Member

reconbot commented Jul 24, 2017 via email

@ghost
Copy link

ghost commented Jul 24, 2017

I honestly have no idea, I'm just following what was written before as it seems the only way to find how it works :) However if it's not needed I'll skip the step.

Step 9, not sure what to do with this error

.\node_modules\.bin\electron-rebuild

throws:

G:\ART\nodejs\ardu\node_modules\electron-rebuild\lib\src\rebuild.js:33
    constructor(lifecycle, buildPath, electronVersion, arch = process.arch, extraModules = [], forceRebuild = false, hea
derURL = 'https://atom.io/download/electron', types = ['prod', 'optional'], mode = defaultMode) {
                                                            ^

SyntaxError: Unexpected token =
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (G:\ART\nodejs\ardu\node_modules\electron-rebuild\lib\src\cli.js:16:19)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)

@jacobq
Copy link
Contributor

jacobq commented Jul 24, 2017

@franz1900 do you get any more meaningful error message(s) if you run DEBUG=* .\node_modules\.bin\electron-rebuild instead?

@reconbot
Copy link
Member

reconbot commented Jul 24, 2017 via email

@ghost
Copy link

ghost commented Jul 24, 2017

@reconbot ok that seemed to be the issue with that. So, I'm still getting the "Could not locate the binding files" error when I run npm start. I see that the node_modules/serialport/build/Release folder is still empty after the rebuild.

To recap the steps I've done so far.

Node v6.11.1
Electron v1.6.11
Powershell (Admin) except for steps 11/12
1)  npm install electron --save-dev
2)  Python2.7.3 was already installed in the computer
3)  Have Visual Studio 2017 installed with C++ tools
4)  set VCTargetsPath="C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\"
5)  npm install -g node-gyp
6)  npm install serialport --save-dev
7)  npm install electron-rebuild --save-dev
8)  .\node_modules\.bin\electron-rebuild
9)  del .\node_modules\nslog\build\Release\nslog.node (Previous stage should give error)
10) MINGW64to do the following 2 steps
11) rm -rf node_modules/serialport/build/Release/*
12) rm -rf node_modules/ffi/build/Release/*
13) exit (return to powershell)
14) .\node_modules\.bin\electron-rebuild

I tried again on a total new project and now I get an error on npm install serialport --save-dev

npm install serialport --save-dev

> serialport@5.0.0-beta8 install G:\ART\nodejs\ardu\node_modules\serialport
> node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download(undefined): https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/d
ownload/5.0.0-beta8/serialport-v5.0.0-beta8-node-v48-win32-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for serialport@5.0.0-beta8 and node@6.11.1 (node-v48 ABI) (falling back t
o source compile with node-gyp)

G:\ART\nodejs\ardu\node_modules\serialport>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_module
s\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" clean )  else (node "" clean )

G:\ART\nodejs\ardu\node_modules\serialport>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_module
s\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" configure --fallback-to-build --module=G:\ART\nodej
s\ardu\node_modules\serialport\build\Release\serialport.node --module_name=serialport --module_path=G:\ART\nodejs\ardu\n
ode_modules\serialport\build\Release --python=C:\Python27\python.exe --msvs_version=2017 )  else (node "" configure --fa
llback-to-build --module=G:\ART\nodejs\ardu\node_modules\serialport\build\Release\serialport.node --module_name=serialpo
rt --module_path=G:\ART\nodejs\ardu\node_modules\serialport\build\Release --python=C:\Python27\python.exe --msvs_version
=2017 )
Traceback (most recent call last):
 File "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\gyp_main.py", line 16, in <module>
   sys.exit(gyp.script_main())
 File "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 545, in script_m
ain
   return main(sys.argv[1:])
 File "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 538, in main
   return gyp_main(args)
 File "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 514, in gyp_main
   options.duplicate_basename_check)
 File "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 98, in Load
   generator.CalculateVariables(default_variables, params)
 File "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\generator\msvs.py", line 1900, in C
alculateVariables
   generator_flags.get('msvs_version', 'auto'))
 File "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\MSVSVersion.py", line 434, in Selec
tVisualStudioVersion
   versions = _DetectVisualStudioVersions(version_map[version], 'e' in version)
KeyError: '2017'
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configur
e.js:305:16)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Windows_NT 10.0.15063
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node
-gyp\\bin\\node-gyp.js" "configure" "--fallback-to-build" "--module=G:\\ART\\nodejs\\ardu\\node_modules\\serialport\\bui
ld\\Release\\serialport.node" "--module_name=serialport" "--module_path=G:\\ART\\nodejs\\ardu\\node_modules\\serialport\
\build\\Release" "--python=C:\\Python27\\python.exe" "--msvs_version=2017"
gyp ERR! cwd G:\ART\nodejs\ardu\node_modules\serialport
gyp ERR! node -v v6.11.1
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'node-gyp.cmd configure --fallback-to-build --module=G:\ART\nodejs\ardu
\node_modules\serialport\build\Release\serialport.node --module_name=serialport --module_path=G:\ART\nodejs\ardu\node_mo
dules\serialport\build\Release --python=C:\Python27\python.exe --msvs_version=2017' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (G:\ART\nodejs\ardu\node_modules\serialport\node_modules\node-pr
e-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:106:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:891:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
node-pre-gyp ERR! System Windows_NT 10.0.15063
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "G:\\ART\\nodejs\\ardu\\node_modules\\serialport\\node_m
odules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd G:\ART\nodejs\ardu\node_modules\serialport
node-pre-gyp ERR! node -v v6.11.1
node-pre-gyp ERR! node-pre-gyp -v v0.6.36
node-pre-gyp ERR! not ok
Failed to execute 'node-gyp.cmd configure --fallback-to-build --module=G:\ART\nodejs\ardu\node_modules\serialport\build\
Release\serialport.node --module_name=serialport --module_path=G:\ART\nodejs\ardu\node_modules\serialport\build\Release
--python=C:\Python27\python.exe --msvs_version=2017' (1)
npm WARN ardu@1.0.0 No repository field.
npm ERR! Windows_NT 10.0.15063
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "ins
tall" "serialport" "--save-dev"
npm ERR! node v6.11.1
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE

npm ERR! serialport@5.0.0-beta8 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the serialport@5.0.0-beta8 install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the serialport package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs serialport
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls serialport
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     G:\ART\nodejs\ardu\npm-debug.log

@ghost
Copy link

ghost commented Jul 24, 2017

it's working!! (not sure how/why/when/what but it's working!)

@fdeitelhoff
Copy link

@franz1900 Can you recap what you've done? Because this "it's working" isn't helpful and can be found everywhere one the internet.

@ghost
Copy link

ghost commented Jul 24, 2017

@fdeitelhoff I was driving and I was going to do it now that I arrived home ;)

System

- Win10 Home x64 Build 15063

these are the release I have

- Node v6.11.1
- Electron v1.6.11
- npm v5.3.0

I've used

- Powershell (Admin) except for steps 9/10

I already had

-  Python 2.7.3 installed in the computer
-  Visual Studio 2017 installed with C++ tools (I also have win 8.1 SDK and other things so I can't confirm what is necessary and what is not)

Steps

1.  npm install electron --save-dev
2.  set VCTargetsPath="C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\"
3.  npm install -g node-gyp
4.  npm install serialport --save-dev
5.  npm install electron-rebuild --save-dev
6.  .\node_modules\.bin\electron-rebuild
7.  del .\node_modules\nslog\build\Release\nslog.node (Previous stage should give error)
8.  MINGW64 to do the following 2 steps
9.  rm -rf node_modules/serialport/build/Release/*
10. rm -rf node_modules/ffi/build/Release/*
11. exit (return to powershell)
12. .\node_modules\.bin\electron-rebuild

@reconbot
Copy link
Member

reconbot commented Jul 24, 2017 via email

@xiaoweibaniu
Copy link

this error is ??

image

@lock lock bot locked and limited conversation to collaborators Feb 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests