Node-serialport: Tracking Electron support

Created on 4 Jun 2015  Â·  122Comments  Â·  Source: serialport/node-serialport

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-desktopnode_modules\serialport\build\serialport\v1.7.4\Releasenode-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?

Most helpful comment

Had a hard time figuring this out, electron-rebuild did not work.

Solution

  1. Add this npm script to package.json:
    "postinstall": "cd node_modules/serialport && ./node_modules/.bin/node-pre-gyp rebuild --target=1.3.1 --arch=x64 --dist-url=https://atom.io/download/atom-shell",
  1. Make sure to edit --target=x.x.x to match your version of electron-prebuilt.
  2. Reinstall.
rm -fr node_modules
npm install

OS X: 10.11.6
serialport: 4.0.1
electron-prebuilt: 1.3.1

All 122 comments

Same here

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 [email protected]
wrote:

Same here

—
Reply to this email directly or view it on GitHub
https://github.com/voodootikigod/node-serialport/issues/538#issuecomment-108927479
.

  • 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
  });

});

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

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)

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)

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

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:

https://github.com/usefulthink/node-serialport/commit/c5aace891834bd7b9b94f72e4420554721026a4f

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?

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..

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?

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

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.

Thank you so much for writing this! Fully agree.

@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.binelectron-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

@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 :+1:). Cheers!

@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 :)

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?

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.

@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.

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 https://github.com/voodootikigod/node-serialport/issues/402. Any idea what might cause something like this? I realize this isn't really on topic but I am completely clueless.

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.

I believe this should help but have yet to confirm: https://github.com/mapbox/node-pre-gyp/pull/175

@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)

@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.

Thanks!

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

The regular serialport worked on OSX.

@vjpr Glad it works :) Let me know if there is anything else I can help you with...

As soon as regular serialport works on all platforms I can start deprecating serialport-electron which was always meant as a temporary solution.

confirmed that I can use serialport v2.0.2 in electron-prebuilt v34.0.1 on OSX Yosemite, NodeJS 4.x. Did need electron-rebuild to be installed and run additionally.

@noopkat electron 0.34.2 with serialport 2.0.2 confirmed. Need to use node 4.x (v46) to install serialport module, otherwise the version number will not be correct(5.0.0 v47) for Electron

@weiway good to know, thank you!

same issue with
node 4.2.0
electron-prebuilt 0.34.2
serialport 2.0.2

App threw an error when running [Error: A dynamic link library (DLL) initializat
ion routine failed.
E:\NOTE.JS\examples\dcAlram\app\node_modules\serialport\build\Release\node-v46-win32-x64\serialport.node]

I can use serialport v2.0.2 in electron v34 on OSX Yosemite, NodeJS 4.x but the CPU is very High (130%) in Electron. but with a simple code in standalone node that read every port at 115200 (like in my Electron app), the cpu is very low. So the probleme I think is when serialPort is in Electron?

I ran into some new issues with serialport, electron v35, and windows. I managed to blindly stumble across a solution by using a combination of electron-rebuild to execute node-gyp and rebuild with electron v35 headers and a manual move of the serialport.node file from node_modules/serialport/build/Release/electron-v0.35-win32-x64 into node_modules/serialport/build/Release/node-v46-win32-x64. It worked, but definitely seems wrong.

I definitely had to use the version from electron-rebuild, as well (probably since I have node v5 installed on my machine). I tried a lot of steps along the way, including grabbing the prebuilt version of v64-win32-x64 from the releases page as well as building serialport locally, but nothing worked other than the electron-rebuild file move detailed above.

@Tibus Yes, that's a problem with serialport module. One workaround is to use the serialport in another node process

Hi, I'm stuck with the problem "Expected 46, got 47"... but i'm using node v4.2.6 ... I installed serialport and ran electron-rebuild

@rafaelcorreiapoli this works for me. Tested on Mac (node.js 5.5.0) and Windows (node.js 5.6.0).

package.json

{
  "devDependencies": {
    "electron-prebuilt": "^0.36.7",
    "electron-rebuild": "^1.1.3"
  },
  "scripts": {
    "start": "electron app",
    "preinstall": "cd app && bower install && npm install && cd .. && electron-rebuild -v 0.36.7 -p -f -m app -w serialport -e node_modules/electron-prebuilt",
    "clean": "rm -rf node_modules && rm -rf app/node_modules && rm -rf app/bower_components"
  }
}

app\package.json

{
  "main": "main.js",
  "dependencies": {
    "async": "^1.5.2",
    "batch": "^0.5.3",
    "h5.modbus": "^0.1.0",
    "serialport": "^2.0.6"
  }
}

then to be sure that everything is clear

$ npm run clean

next step is instalation/compilation

$ npm install

finally the execution

$ npm start

@weiway but how to run another process of node inside a Electron app?

Thank's @weiway, your node-seriaport-worker work really well and my CPU usage is normal now!
Thank's verry much.

TL;DR Try running as administrator if electron-rebuild is failing.

@Mirodil, did you ever resolve the issue you encountered? I was fighting the same thing on my Windows machine. My project uses electron 0.36.11 (0.37.x seemed to have compile issues for me just like in this issue and environment is node v5.9.0, npm v3.7.3, and Windows 10 (64-bit) w/ Visual Studio express 2015 and Python 2.7.11 installed. I can successfully run cd node_modules\serialport; node-pre-gyp install --build-from-source and run my (Mocha) tests. However, when I would try to run electron it blows up with App threw an error when running [Error: A dynamic link library (DLL) initialization routine failed. \\?\C:\Users\Jacob\Documents\KFMT\kanolysis\node_modules\serialport\build\Release\node-v47-win32-x64\serialport.node].
image

I thought perhaps this is related to a node vs. electron incompatibility, so tried running electron-rebuild --pre-gyp-fix -f but it blew up with some errors. Upon closer inspection I noticed two things, one was that the name apparently changed such that I had to append .cmd and the other was that there was some kind of permission problem (why? I have no idea as I was doing all this in my home/Documents directory as my user). I then changed the git bash (MINGW64) shell shortcut to always run as an administrator....next time I ran that same electron-rebuild.cmd it succeeded and launched successfully in electron. Notably, there was a new electron-v0.36-win32-x64 in the module's build/Releases/ folder in addition to the node one. (Hopefully this is helpful to someone else finding this....these problems can be overwhelming to someone not familiar with the Windows + node ecosystem)

I am about at the same point as @jacobq, and tearing my hair out!

Dependency versions:
"serialport": "2.0.6"
"electron-prebuilt": "0.36.7",
"electron-rebuild": "^1.1.3",

Removed completely node_modules and ran npm install.

Serialport was successfully built using MS compiler to dir named node-v47-win32-ia32 (not sure why it is ia32 and not x64?).

Trying to run electron I have "DLL initialization routine failed", so it is finding the serialport.node file.

Trying to run rebuild_electron as admin I get the following output (node version v5.9.0):

npm run rebuild

> [email protected] rebuild C:\t
> electron-rebuild -v 0.36.7 -p -f -m app -w serialport -e node_modules/electron-prebuilt

spawn node ENOENT
Error: spawn node ENOENT
    at exports._errnoException (util.js:890:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:182:32)
    at onErrorNT (internal/child_process.js:348:16)
    at _combinedTickCallback (node.js:383:13)
    at process._tickCallback (node.js:407:11)

npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\opt\\nodejs\\node.exe" "C:\\Users\\alfie\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "rebuild"
npm ERR! node v5.9.0
npm ERR! npm  v3.8.0
npm ERR! code ELIFECYCLE
npm ERR! [email protected] rebuild: `electron-rebuild -v 0.36.7 -p -f -m app -w serialport -e node_modules/electron-prebuilt`
npm ERR! Exit status 4294967295

Any help much appreciated. Feels like I'm nearly there... just one hurdle to go ;)

@jugglingcats I think you're seeing the DLL error because the module that's there isn't the one you need for electron (i.e. the one electron-rebuild is supposed to make for you).
In case it's helpful, I was using node-serialport 2.0.7-beta1, electron-prebuilt 0.36.11, and electron-rebuild 1.1.3. I have 64-bit versions of NodeJS and Python 2.7.11 installed as well as Visual Studio 2015 Express w/ C/C++ support (though I'm not sure if any/all of these are needed). If I go into node_modules\serialport\ and run node-pre-gyp rebuild or node-pre-gyp install --build-from-source it shows a few warnings but succeeds. Running electron-rebuild was the touchy one for me. I was getting EPERM (permission error). ENOENT just means "No such file or directory" so perhaps there is a problem with your path or a file/dir needed during the build process?

Eventually had similar results to @dvlsg. Had to rename the .node file but it is working. Thanks @jacobq for your input. Am not sure ultimately what was causing ENOENT but it went away at some point during my hackfest.

Installed Visual Studio Community 2015 with C++ support and the Windows 8 and 10 SDKs (was getting missing windows.h using the SDK tech preview mentioned elsewhere).

Uninstalled node win32 and installed node x64. Deleted global node cache and node_modules.

Fixed issue with node-gyp not finding python.exe by linking to python2.7.exe.

Ran electron-rebuild.

Renamed directory of node file from node_modules/serialport/build/Release/electron-v0.35-win32-x64 to node_modules/serialport/build/Release/node-v46-win32-x64.

Spun around 3 times and recited a silent prayer... and :tada:.

Windows 10
node: v5.9.0 (x64)
serialport: 2.0.6
electron-prebuilt: 0.36.7
electron-rebuild: 1.1.3
msvs_version = "2015"

I can only seem to require serialport from main.js, but am then passing it via remote.getGlobal() in my app script.

I am not seeing the high CPU issue (at least not in initial testing).

Hope this can help others, because this is one of my most painful experiences getting something running in quite a while ;)

No dice for me I'm afraid -

OSX Yosemite
node 4.3.1
serialport 2.0.6 and 2.0.2 tried
electron-prebuilt 0.36.7 and 0.34.1 tried
electron-rebuild 1.1.3

electron-rebuild appears to do something:

node-pre-gyp fixer: node_modules/gulp-watch/node_modules/chokidar/node_modules/fsevents/lib/binding/Release/electron-v0.34-darwin-x64 copied to node_modules/gulp-watch/node_modules/chokidar/node_modules/fsevents/lib/binding/Release/node-v47-darwin-x64
node-pre-gyp fixer: node_modules/serialport/build/Release/electron-v0.34-darwin-x64 copied to node_modules/serialport/build/Release/node-v47-darwin-x64

given the following command:

electron-rebuild -v 0.34.2 -f -p -m node_modules/ -e node_modules/electron-prebuilt/

Have tried electron-serialport too but not working either. Pretty much seeing the same error as everyone else where electron is expecting a different version than that done by the npm install.

Basically once app tries to connect it throws:

Error: Module version mismatch. Expected 47, got 46.
    at Error (native)
    at process.module.(anonymous function) [as dlopen] (ATOM_SHELL_ASAR.js:157:20)
    at Object.Module._extensions..node (module.js:450:18)
    at Object.module.(anonymous function) [as .node] (ATOM_SHELL_ASAR.js:157:20)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/Users/ajfisher/dev/tmp/robotnik/node_modules/serialport/serialport.js:14:25)
    at Module._compile (module.js:425:26)

When the file is actually at:

/Users/ajfisher/dev/tmp/robotnik/node_modules/serialport/build/Release/node-v47-darwin-x64/serialport.node

Consistent behaviour on RPi as well (which is ultimately my target for this).

Any ideas much appreciated as I'm pulling out hair on this now.

@ajfisher Have you tried to use Node v5.x.x when rebuilding? And you might need to do some renaming.

https://github.com/OpenBCI/openbci-js-sdk/issues/31#issuecomment-205059018 is another case of electron-rebuild working out

So node5 seems like a reasonable approach? I am on RPi so can control the
environment to a point so will give that a crack and see what happens.

On Mon, Apr 4, 2016, 08:58 Francis Gulotta [email protected] wrote:

OpenBCI/openbci-js-sdk#31 (comment)
https://github.com/OpenBCI/openbci-js-sdk/issues/31#issuecomment-205059018
is another case of electron-rebuild working out

—
You are receiving this because you were mentioned.

Reply to this email directly or view it on GitHub
https://github.com/voodootikigod/node-serialport/issues/538#issuecomment-205070433

Hi Everyone,
I moved the binaries around in beta4, I don't know if that's going to be a problem for any of you but I wanted someone who's using electron to give it a try. We also upgraded nan which I believe helps work with the newest electron.

Please try it out [email protected] and report back! #733

I've gotten a few reports that beta4 works great with electron rebuild. (and also for nwjs!) Can someone submit a docs patch for close #741? I'm not super familiar with electron but I think a lot of people would benefit from this threads collective experience.

Thanks!

I'll see If I can't do it. Bug me here or in gitter if I fail to do so ;)

Also if you all could test [email protected] it's our release candidate. It's got a single change from beta4 around where the binaries go that should make your life a little easier when you rebuild.

@reconbot Just tried out Beta5, Default node install works.. a bit messier in the build/Release folder, but it works. What still does not work, is that since there's only one binary output folder, electron-rebuild will refuse to step on it. You must delete serialport.node before rebuild will take over, but rebuild does work beautifully (and quietly!) after that.

Unfortunately for my use case I need to be able to have both of these binaries (Node.js terminal and Electron) available as I allow users to run serialport in just Electron, or in both Electron and a Node.js child process. This worked just fine in previous releases as I could actually keep the binaries for all the OS' together, and would then be able to also keep the v46 node v4.x built bins right next to the v47s for the latest node5 in Electron. Truth is if they use the same binary, I have yet to see the actual fault, as long as they use the same module version.

@reconbot [email protected] worked well for me with Electron 0.37.4, I just had to delete serialport.node.

Thank you.

That's annoying, good to hear though. I'll open an issue with them if there
isn't one already.

On Sat, Apr 9, 2016, 4:48 PM pimpaa [email protected] wrote:

@reconbot https://github.com/reconbot [email protected] worked
well for me with Electron 0.37.4, I just had to delete serialport.node.

Thank you.

—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/voodootikigod/node-serialport/issues/538#issuecomment-207852190

Are there other binary packages that work without needing this extra step of removing the binary?

So I've just tried on my Mac plus an RPi, both running 5.10.x (using nvm) -
straight install using serial port beta 5 plus electron latest plus Johnny
five latest.

Worked fine on both platforms without an issue now it seems.

On Sun, Apr 10, 2016, 13:14 Francis Gulotta [email protected]
wrote:

Are there other binary packages that work without needing this extra step
of removing the binary?

—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/voodootikigod/node-serialport/issues/538#issuecomment-207904613

Hi guys!
Please... someone help me!

Using electron and serialport

When I run:

Error: Uma rotina de inicialização da biblioteca de vínculo dinâmico (DLL) falhou.
\?\C:\projeto\meia-maratona-electronnode_modulesserialport\build\Releaseserialport.node
at Error (native)
at process.module.(anonymous function) as dlopen
at Object.Module._extensions..node (module.js:440:18)
at Object.module.(anonymous function) as .node
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at bindings (C:\projeto\meia-maratona-electronnode_modules\bindings\bindings.js:76:44)
at Object. (C:\projeto\meia-maratona-electronnode_modulesserialportserialport.js:16:44)

What can i do for this?

"electron-prebuilt": "^0.37.4"
"serialport": "2.0.7-beta5"
node version : 5.10.1
npm version : 3.8.6
python version: 2.7.11

@gohackfelipe Can you try [email protected] and then run electron-rebuild after installing?

Hi @reconbot ..

I did what you asked for and did not work.. The same issue is happening...

Error: Uma rotina de inicialização da biblioteca de vínculo dinâmico (DLL) falhou.
\?\C:\projeto\meia-maratona-electronnode_modulesserialport\build\Releaseserialport.node
at Error (native)
at process.module.(anonymous function) as dlopen
at Object.Module._extensions..node (module.js:440:18)
at Object.module.(anonymous function) as .node
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at bindings (C:\projeto\meia-maratona-electronnode_modules\bindings\bindings.js:76:44)
at Object. (C:\projeto\meia-maratona-electronnode_modulesserialportserialport.js:16:44)

Do you have the output of the rebuild?

On Tue, Apr 19, 2016, 6:03 PM Felipe Ribeiro [email protected]
wrote:

Hi @reconbot https://github.com/reconbot ..

I did what you asked for and did not work.. The same issue is happening...

Error: Uma rotina de inicialização da biblioteca de vínculo dinâmico (DLL)
falhou.

\?\C:\projeto\meia-maratona-electronnode_modulesserialport\build\Releaseserialport.node
at Error (native)
at process.module.(anonymous function) as dlopen
at Object.Module._extensions..node (module.js:440:18)
at Object.module.(anonymous function) as .node
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)

at bindings
(C:\projeto\meia-maratona-electronnode_modules\bindings\bindings.js:76:44)

at Object.
(C:\projeto\meia-maratona-electronnode_modulesserialportserialport.js:16:44)

—

You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/voodootikigod/node-serialport/issues/538#issuecomment-212147836

Looks like that i have another problem when i try to execute the electron-rebuild

PS C:\projeto\meia-maratona-electron> .\node_modules\.bin\electron-rebuild.cmd

> [email protected] install C:\projeto\meia-maratona-electron\node_modules\nslog
> node-gyp rebuild


C:\projeto\meia-maratona-electron\node_modules\nslog>if not defined npm_config_node_gyp (node "C:\projeto\meia-maratona
electron\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebui
d )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  main.cc
  nslog_win.cc
  win_delay_load_hook.c
LINK : fatal error LNK1104: cannot open file 'libcpmt.lib' [C:\projeto\meia-maratona-electron\node_modules\nslog\build\
slog.vcxproj]

npm WARN prefer global [email protected] should be installed with -g
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\projeto\meia-maratona-electron\node_modules\npm\node_modules\node-gyp\lib
build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:100:13)
gyp ERR! stack     at ChildProcess.emit (events.js:185:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\projeto\\meia-maratona-electron\\node_modules\\npm\\node_mo
ules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\projeto\meia-maratona-electron\node_modules\nslog
gyp ERR! node -v v5.10.1
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok

npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\projeto\\meia-maratona-electron\\node_modules\\npm\\bin\\npm-c
i.js" "rebuild" "--runtime=electron" "--target=0.37.6" "--arch=x64"
npm ERR! node v5.10.1
npm ERR! npm  v3.8.6
npm ERR! code ELIFECYCLE
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
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 nslog package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs nslog
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls nslog
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\projeto\meia-maratona-electron\node_modules\npm-debug.log

Process exited with code: 1
Error: Process exited with code: 1
    at ChildProcess.<anonymous> (C:\projeto\meia-maratona-electron\node_modules\electron-rebuild\lib\spawn.js:55:26)
    at emitTwo (events.js:100:13)
    at ChildProcess.emit (events.js:185:7)
    at maybeClose (internal/child_process.js:850:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)

Can we ship all the binaries with serialport some how? When we package these electron appson OS X for say windows or linux, I see an error where the correct serialport.node version is not found. We can hot fix this by installing the correct serialport version but it's entirely based on your system.

What tells serialport to build 47 instead of 46? I would really love some clarity on that.

Whichever node is doing the compiling. If you're using electron rebuild you'll get the version it provides, if you're doing npm rebuild you'll get the version of your nodejs.

I'm getting a different error, something about the tools version and msbuild:

$ ./node_modules/.bin/electron-rebuild.cmd --force --pre-gyp-fix

...

MSBUILD : error MSB4132: The tools version "2.0" is unrecognized. Available tools versions are "14.0", "4.0".

npm WARN prefer global [email protected] should be installed with -g
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\mike\Desktop\dronefuse-client\node_modules\npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:100:13)
gyp ERR! stack     at ChildProcess.emit (events.js:185:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)
gyp ERR! System Windows_NT 10.0.10586
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\mike\\Desktop\\dronefuse-client\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\mike\Desktop\dronefuse-client\node_modules\nslog
gyp ERR! node -v v5.10.1
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok

npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\mike\\Desktop\\dronefuse-client\\node_modules\\npm\\bin\\npm-cli.js" "rebuild" "--runtime=electron" "--target=0.37.8" "--arch=x64"

Same error with node-pre-gyp rebuild

Versions:

  • Node v5.10.1
  • Electron v0.37.8
  • Windows 10
  • Python 2.7.11
  • npm config set msvs_version 2015
  • npm config set python python

Everything works peachy on the OS X side of things, at least.

@mikew You might want to try installing MS Visual Studio Express / Community (free version) instead of their BuildTools package. I'm not an expert by any means but have found that to be the most reliable way to get gyp to build things right on Windows.
https://github.com/chjj/pty.js/issues/60#issuecomment-85797012

@jacobq yep, seems to be the case.

Wish I knew what component of VS is actually needed, because the build succeeds before VS Community 2015 is finished installing.

On downloading all the binaries (cc @pushtheworldllc @techninja and others)

We're currently using bindings to find and require the binary and we're placing the binary in the standard location /build/{configuration}/serialport.node (where configuration is usually Release).

For node binaries. What would work perfectly would be if you removed the downloaded binary from /build/Release/ and download all the available binaries and put them in

/compiled/{ABI version}/{platform}/{arch}/

We already name the files with the right information eg serialport-v3.1.1-node-v11-darwin-x64.tar.gz or serialport-v3.1.1-node-v48-win32-x64.tar.gz.

I'd be happy to merge a utility script that does that so you could type npm run download-all-precompiled-binaries and then be set for all platforms when running node.

Electron binaries will work with that directory structure too. I don't know how to prebuild them for download but if you build them and move them to the right location the app will function and you can ship multiple platforms at one time.

The node-pre-gyp reveal output from a successful compilation of serialport for Electron 1.1.0 (node 6.1.0, Chromium 50.0.2661.102) on Win7x64 indicates "node-v43" for the "node_abi".

$node_modules\.bin\node-pre-gyp.cmd reveal --target=1.1.0 --arch=x64 --dist-url=https://atom.io/download/atom-shell
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using [email protected]
node-pre-gyp info using [email protected] | win32 | x64
{
  "name": "serialport",
  "configuration": "Release",
  "module_name": "serialport",
  "version": "3.1.2",
  "prerelease": "",
  "build": "",
  "major": 3,
  "minor": 1,
  "patch": 2,
  "runtime": "node",
  "node_abi": "node-v43",
  "target": "1.1.0",
  "platform": "win32",
  "target_platform": "win32",
  "arch": "x64",
  "target_arch": "x64",
  "module_main": "./lib/serialport",
  "toolset": "",
  "host": "https://github.com/voodootikigod/node-serialport/releases/download/3.1.2/",
  "module_path": "E:/mbot/electron-serialport/electron-quick-start/node_modules/serialport/build/Release",
  "module": "E:/mbot/electron-serialport/electron-quick-start/node_modules/serialport/build/Release/serialport.node",
  "remote_path": "",
  "package_name": "serialport-v3.1.2-node-v43-win32-x64.tar.gz",
  "staged_tarball": "build/stage/serialport-v3.1.2-node-v43-win32-x64.tar.gz",
  "hosted_path": "https://github.com/voodootikigod/node-serialport/releases/download/3.1.2/",
  "hosted_tarball": "https://github.com/voodootikigod/node-serialport/releases/download/3.1.2/serialport-v3.1.2-node-v43-win32-x64.tar.gz"
}
node-pre-gyp info ok

I've forked and adapted the electron-quick-start app to get the latest Electron to 'npm install' with serialport. Check electron-quick-start-serialport. (tested in Win7x64 with node 6.1.0)

To test #812 it's just a matter to check if the serialport binaries fail to download (as they currently do not exist) and falls back to building it.

Hi.. I get this error when trying to open electron app using serialport. Any idea of what could be wrong?
If there's a solution could you please explain step by step...

Thanks
error

@andresfuseau I believe that most likely means that the module was not (re)built properly for the node version used by electron. I would suggest removing the files node_modules/serialport/build/Release/* then using node_modules/.bin/electron-rebuild -e node_modules/electron-prebuilt -f to rebuild it. (I assume you have installed electron-rebuild in the project.)

@jacobq Thanks for your help but still don't get it. I already succesfully installed electron-rebuild and deleted the files in node_modules/serialport/build/Release/* .. in which folder should I run node_modules/.bin/electron-rebuild -e node_modules/electron-prebuilt -f??
If I run it on ./.bin folder I get: Unable to find electron-prebuilt's version number, either install it or specify an explicit version
Tried also running in my app root and get this:
C:\Users\Andr�s\AppData\Roaming\npmnode_moduleselectron-rebuildlib\headers.node-gyp\iojs-1.1.1Release\iojs.lib : fatal error LNK1107: invalid or corrupt file: cannot read at 0x1C6A76 [C:\Users\Andr�s\AppData\Roaming\npmnode_moduleselectron-rebuildnode_modules\nslog\build\nslog.vcxproj

@andresfuseau, yes, run in project root. You're getting closer. It looks like electron-rebuild is not working because of your build tools being messed up or something. Could it perhaps be related to the special character in the pathname? Windows is super fussy about that kind of thing.

Anyone here ever see anything like #838 before? I'm stabbing in the dark trying to debug.

I read this post, but I am still facing the DLL issue.

My project uses electron, react/redux and an external library from Particle.io (IOT company).

Whenever I build it on my mac it works 100%, but I am struggling with Windows 10.

Project code: https://github.com/SmartPowerSocket/DesktopApp

img_2830

test

I got Visual Studio Community 2013, Python 2.7 and Node 6.20 installed on my Windows 10 machine.

This project got two node_modules folder. Having said that, one is for the electron + react/redux app, the other is for the particle library.

Any tips?

Had a hard time figuring this out, electron-rebuild did not work.

Solution

  1. Add this npm script to package.json:
    "postinstall": "cd node_modules/serialport && ./node_modules/.bin/node-pre-gyp rebuild --target=1.3.1 --arch=x64 --dist-url=https://atom.io/download/atom-shell",
  1. Make sure to edit --target=x.x.x to match your version of electron-prebuilt.
  2. Reinstall.
rm -fr node_modules
npm install

OS X: 10.11.6
serialport: 4.0.1
electron-prebuilt: 1.3.1

@arve0, you are a life saver. I spent a good 2 hours on this trying to figure out how to build the lib for the new electron version... Thanks.

I'd gladly accept a PR to add some docs around this. I'm not very familiar with electron so I don't want to be the one writing the docs. Happy to help edit and review.

-Francis

I'm not sure why people are having issues with electron-rebuild. We're using it fine on OS X and Windows with node-serialport:

node_modules/.bin/electron-rebuild --force --pre-gyp-fix --which-module serialport --module-dir electron-app/node_modules

Change electron-app/node_modules to the path of node_modules for your electron app. So if you're only using one package.json it would be node_modules. If your package.json for electron is at some/dir/package.json then you want some/dir/node_modules.

Here is our script to install dependencies for reference: https://gist.github.com/mikew/77259047ef31a2e49b124ff8b29a9745

I'm still having horrific build issues. I left it alone for a couple weeks and will try all these new attempts. I'm trying to use serial port in the main provess, anyone else too?

I'm not sure why people are having issues with electron-rebuild. We're using it fine on OS X and Windows with node-serialport:

@mikew Well, in my case, it was that my installed node version was on an older v8 (or node?) version than electron, which caused (I think) a mismatch in module version packaging. I got an error like this:

Error: Module version mismatch. Expected 49, got 48.

Will node_modules/.bin/electron-rebuild --force --pre-gyp-fix --which-module serialport --module-dir electron-app/node_modules fix that? Might be that you are on an older version of electron that matches your node version?

To be clear, the electron version must match the installed node version. If not, explicit tell the compiler where to find headers and to which version to build.

@mikew i tried with electron-rebuild any ideas?

electron-serialport-failure

Then i tried dragging and dropping in the downloaded Release from the releases page and got this error:
electron-serialport-failure2

I have the same issue with @aj-ptw,
I package my electron-serialport app on MAC OSX, it's nomal,
then, I run it on win32 x64, the issue happened,
63de5c1431fa7c14174418e89f589431

Here is my package.json

{
  "name": "tool",
  "version": "1.0.0",
  "description": "tool",
  "main": "main.js",
  "scripts": {
    "install": "node-pre-gyp install --fallback-to-build --runtime=electron --target=1.3.3 --target_arch=x64 --directory=./node_modules/serialport --update-binary --dist-url=https://atom.io/download/atom-shell",
    "start": "electron main.js",
    "package-win32": "electron-packager ./ tool --prune --ignore=dist --platform=win32 --arch=x64 --overwrite --out ./dist"
  },
  "devDependencies": {
    "electron-prebuilt": "^1.3.3",
    "node-gyp": "^3.4.0",
    "node-pre-gyp": "^0.6.29"
  },
  "dependencies": {
    "serialport": "^4.0.1"
  },
  "engine": "^6.3.1"
}

@dfsq1311 i'm still getting it ha, wish i could shed some light for you!

@aj-ptw I'm also getting it. I'm building it on win32 x64.

when I build on windows platform, I get the error "Release\iojs.lib : fatal error LNK1107".

the issue I submit https://github.com/EmergingTechnologyAdvisors/node-serialport/issues/912

I'm having a lot of luck with two package.jsons And using electron-builder also using appvoyer to build for windows.

@aj-ptw can you provide a link to a project example on github, I've just recently started liking at appveyor and electron-builder and managed to get a really bare bones project to deploy an installer into a drafted release, but haven't breached including serialport (our anything really) yet. An example would be super helpful, as electron-builder docs, while good, assume a fair bit of knowledge about how everything interacts.

I've just recently started liking at appveyor and electron-builder and managed to get a really bare bones project to deploy an installer into a drafted release

@vicatcu cool i hope to be there soon!

For starters I am using Electron React Boilerplate and am using this pull request with electron-builder

The critical components so far are using _two_ package.jsons, the important one is the static/package.json file which contains the module (openbci) which is dependent on node-serialport.

Ok so for some magic I we bring in webpack. Electron with webpack leads to separation of main and renderer processes. Where main is the main.js and renderer is bundle.js. I use openbci in the main process, not the render, but anyway I add serialport to the noParse array and openbci to the externals array.

    module: {
        noParse: [/serialport/]
    },
    externals: [
        'openbci'
    ]

I am pretty sure that's everything!

If you got the DLL issue, that means you didn't compile the source well.
I use the following steps to get it work under my Windows 10 x64

  1. first delete c:\temp\electronnode_modulesserialport\buildRelease*
  2. cd c:\temp\electronnode_modulesserialport
  3. ...binnode-gyp rebuild --target=1.3.4 --arch=x64 --dist-url=https://atom.io/download/atom-shell

Then you can see the binary files in the Release folder.
( where c:\temp\electron is my project folder)

My package.json ->

"devDependencies": {
"electron-prebuilt": "^1.3.4",
"electron-rebuild": "^1.2.0",
"node-gyp": "^3.4.0",
"node-pre-gyp": "^0.6.29",
"serialport": "^4.0.1"
}

Thank you so much @arve0 for the solution. Worked like charm! :tada:

Environment:
Windows 7 x64. + Node.js v4.5.0 + npm v3.10.6 + electron v1.3.4 + serialport v4.0.1

For those of you with the "Module version mismatch" errors on Windows, make sure you have the correct electron runtime set as the --target= parameter. This will display on the index.html page if you use the starter template. For example, if you are using 1.4.1 then you will need to run this:

node_modulesserialportnode_modulesnode-pre-gyp\binnode-pre-gyp install --fallback-to-build --runtime=electron --target=1.4.1 --target_arch=x64 --directory=node_modules/serialport/ --update-binary --dist-url=https://atom.io/download/atom-shell

Managed to get serialport working in Electron after trying a number of things. Well, I think_think_ it's working - it's not crashing, or behaving oddly as of yet. Prior to this, the errors/problems that I would get would be: - "Specified procedure not found," error on startup
- Could create the serialport object, but ports could not be opened, and a, "true" was returned for an error on trying to open a port.
- Port could be created, but if created as a persistent variable, the application would crash after a few seconds. If the port was created in a method, it wouldn't always crash, and could open a port and send data. Was very unreliable.
Currently, no crashes if creating/opening the port as a persistent variable in the main window javascript file:
const SerialPort = require('serialport');
var port = new SerialPort('COM4');

My System: Windows 10 Anniversary x64
Node: v6.2.2 32 bit.
Electron 32 bit.

My package.json (the relevant parts):
"devDependencies": {
"electron-prebuilt": "^1.3.4",
"node-gyp": "^3.4.0",
"node-pre-gyp": "^0.6.29",
"serialport": "^4.0.1"
}
serialport will move into the Dependencies, but that's beside the point.

  1. Set environment variables
    set npm_config_disturl=https://atom.io/download/atom-shell
    set npm_config_target=1.4.0
    set npm_config_arch=ia32
    set npm_config_runtime=electron
    set HOME="C:\Users\me.electron-gyp"
    set VCTargetsPath=C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140
  2. Deleted the node_modulesserialport directory
  3. npm install serialport --build-from-source

Here is the full trick list I had to do:

  1. npm install electron --save-dev
  2. Install Python2.7 to PATH
  3. Have Visual Studio 2015 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 ffi --save-dev
  7. npm install serialport --save-dev
  8. npm install electron-rebuild --save-dev
  9. .\node_modules\.bin\electron-rebuild
  10. del .\node_modules\nslog\build\Release\nslog.node (Previous stage should give error)
  11. bash (ubuntu on windows, removing recursively is not something I do from cmd)
  12. rm -rf node_modules/serialport/build/Release/*
  13. rm -rf node_modules/ffi/build/Release/*
  14. exit (return to command prompt)
  15. .\node_modules\.bin\electron-rebuild

I must say, that the tricks one has to do get native modules working with Electron in Windows is so complicated, that it kind of ruins the npm install when it just doesn't work.

I don't know what is a good solution for woes of Windows, but usually if it's possible things should be prebuilt for Windows, it's so damn tricky to rebuild stuff with it sometimes.

I'm adding what I had to do:

  1. Install electron-rebuild: npm install --save-dev electron-rebuild.
  2. Manually remove the node_modules/serialport/build/ folder.
  3. Check electron version with electron -v.
  4. Rebuild: npm rebuild serialport --runtime=electron --target=<your-electron-version> --arch=x64 --dist-url=https://atom.io/download/atom-shell.

This is what i did to make it work:

1) Install node-pre-gyp globaly:

npm install -g node-pre-gyp

2) 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

3) 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. :+1:

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).

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

-Jacob

On Jan 18, 2017 6:53 PM, "Fabian Deitelhoff" notifications@github.com
wrote:

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).

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/EmergingTechnologyAdvisors/node-serialport/issues/538#issuecomment-273649916,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABjss9lJD2CZcTbwifn5c_3-5FQ-By6jks5rTrQmgaJpZM4E3qag
.

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).

@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

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.

I agree =)

On Thu, Jan 19, 2017, 6:07 PM Jari Pennanen notifications@github.com
wrote:

I think this issue should be closed, right? This is not an issue, hasn't
been a long time with node-serialport, it 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.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/EmergingTechnologyAdvisors/node-serialport/issues/538#issuecomment-273927595,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABlbr9c_zmEIzFNctshzyGdoIywKg3wks5rT-zHgaJpZM4E3qag
.

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.

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.

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.

Keep trying!

You need to keep trying different combinations until it works. Webpack with electron and native dependencies is tough to crack.

If your open source post your repo and maybe someone will help!

Try using a boiler plate. This was frustrating for me to but you need to exclude the native dependencies from being web packed. You can literally tell webpack to avoid with "exclude" in your package.json

Make sure you are using a two package.json config, checkout electron boilerplate for example. I'm about to integrate serial port with a production app for OpenBCI Electron hub. I'll post link here once I do, ping me in a week if I forget and youre still stuck.

Good luck! Keep trying!

AJ Keller
Push The World

On Jul 17, 2017, at 12:52 PM, franz1900 notifications@github.com wrote:

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.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

@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.

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 [email protected]
1390 silly linkStuff [email protected] has G:\ART\nodejs\ardu\node_modules\ffi\node_modules as its parent node_modules
1391 verbose linkBins [email protected]
1392 verbose linkMans [email protected]
1393 verbose rebuildBundles [email protected]
1394 verbose rebuildBundles [ 'ms' ]
1395 info install [email protected]
1396 info postinstall [email protected]
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 [email protected] 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: [email protected] 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 [email protected]
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 [email protected] install: `node-gyp rebuild`
1410 error Exit status 1
1411 error Failed at the [email protected] 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 [email protected]
1415 info uninstall [email protected]
1416 verbose unbuild rmStuff [email protected] from G:\ART\nodejs\ardu\node_modules
1417 verbose unbuild rmStuff in G:\ART\nodejs\ardu\node_modules\ffi\node_modules
1418 info postuninstall [email protected]
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 [email protected]
1425 info uninstall [email protected]
1426 verbose unbuild rmStuff [email protected] from G:\ART\nodejs\ardu\node_modules
1427 info postuninstall [email protected]
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

What does ffi have to do with installing serialport?

On Mon, Jul 24, 2017, 6:38 AM franz1900 notifications@github.com wrote:

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:\ARTnodejs\ardunode_modules\ffinode_modules\debug
1389 info linkStuff [email protected]
1390 silly linkStuff [email protected] has G:\ARTnodejs\ardunode_modules\ffinode_modules as its parent node_modules
1391 verbose linkBins [email protected]
1392 verbose linkMans [email protected]
1393 verbose rebuildBundles [email protected]
1394 verbose rebuildBundles [ 'ms' ]
1395 info install [email protected]
1396 info postinstall [email protected]
1397 verbose unlock done using C:\Users\Fran\AppData\Roaming\npm-cache_locks\debug-e6b5658bafc3ef9c.lock for G:\ARTnodejs\ardunode_modules\ffinode_modules\debug
1398 info [email protected] Failed to exec install script
1399 verbose unlock done using C:\Users\Fran\AppData\Roaming\npm-cache_locks\ref-42c84230165c03fd.lock for G:\ARTnodejs\ardunode_modules\ffinode_modules\ref
1400 verbose about to build G:\ARTnodejs\ardunode_modules\ffi
1401 verbose unlock done using C:\Users\Fran\AppData\Roaming\npm-cache_locks\ffi-afc147decab49347.lock for G:\ARTnodejs\ardunode_modules\ffi
1402 verbose stack Error: [email protected] install: node-gyp rebuild
1402 verbose stack Exit status 1
1402 verbose stack at EventEmitter. (C:\Program Filesnodejsnode_modules\npmlib\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. (C:\Program Filesnodejsnode_modules\npmlib\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 [email protected]
1404 verbose cwd G:\ARTnodejs\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 [email protected] install: node-gyp rebuild
1410 error Exit status 1
1411 error Failed at the [email protected] 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\ffinode_modules\ref
1414 info preuninstall [email protected]
1415 info uninstall [email protected]
1416 verbose unbuild rmStuff [email protected] from G:\ARTnodejs\ardunode_modules
1417 verbose unbuild rmStuff in G:\ARTnodejs\ardunode_modules\ffinode_modules
1418 info postuninstall [email protected]
1419 silly gentlyRm G:\ARTnodejs\ardunode_modules\ffinode_modules\ref is being purged from base G:\ARTnodejs\ardu
1420 verbose gentlyRm don't care about contents; nuking G:\ARTnodejs\ardunode_modules\ffinode_modules\ref
1421 silly vacuum-fs purging G:\ARTnodejs\ardunode_modules\ffinode_modules\ref
1422 silly vacuum-fs quitting because other entries in G:\ARTnodejs\ardunode_modules\ffinode_modules
1423 verbose unbuild node_modules\ffi
1424 info preuninstall [email protected]
1425 info uninstall [email protected]
1426 verbose unbuild rmStuff [email protected] from G:\ARTnodejs\ardunode_modules
1427 info postuninstall [email protected]
1428 silly gentlyRm G:\ARTnodejs\ardunode_modules\ffi is being purged from base G:\ARTnodejs\ardu
1429 verbose gentlyRm don't care about contents; nuking G:\ARTnodejs\ardunode_modules\ffi
1430 silly vacuum-fs purging G:\ARTnodejs\ardunode_modules\ffi
1431 silly vacuum-fs quitting because other entries in G:\ARTnodejs\ardunode_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

—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
https://github.com/EmergingTechnologyAdvisors/node-serialport/issues/538#issuecomment-317425066,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABlbkRSmjUJ2SjQW5-gphxbb-sdRjD8ks5sRJ5PgaJpZM4E3qag
.

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)

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

I'm going to guess you need a higher version of node, it's probably a
default argument statement.
http://node.green/#ES2015-syntax-default-function-parameters


Francis Gulotta
[email protected]

On Mon, Jul 24, 2017 at 7:40 AM, franz1900 notifications@github.com wrote:

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.binelectron-rebuild

throws:

G:\ARTnodejs\ardunode_moduleselectron-rebuildlib\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. (G:\ARTnodejs\ardunode_moduleselectron-rebuildlib\src\cli.js:16:19)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)

—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
https://github.com/EmergingTechnologyAdvisors/node-serialport/issues/538#issuecomment-317444403,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABlbh3Npdv5Yz_1DuAWXWQ8OMjJDfauks5sRKzvgaJpZM4E3qag
.

@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

[email protected] install G:\ARTnodejs\ardunode_modulesserialport
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 [email protected] and [email protected] (node-v48 ABI) (falling back t
o source compile with node-gyp)

G:\ARTnodejs\ardunode_modulesserialport>if not defined npm_config_node_gyp (node "C:\Program Filesnodejsnode_module
s\npm\binnode-gyp-bin\....node_modulesnode-gyp\binnode-gyp.js" clean ) else (node "" clean )

G:\ARTnodejs\ardunode_modulesserialport>if not defined npm_config_node_gyp (node "C:\Program Filesnodejsnode_module
s\npm\binnode-gyp-bin\....node_modulesnode-gyp\binnode-gyp.js" configure --fallback-to-build --module=G:\ARTnodej
s\ardunode_modulesserialport\buildReleaseserialport.node --module_name=serialport --module_path=G:\ARTnodejs\ardu\n
ode_modulesserialport\buildRelease --python=C:\Python27\python.exe --msvs_version=2017 ) else (node "" configure --fa
llback-to-build --module=G:\ARTnodejs\ardunode_modulesserialport\buildReleaseserialport.node --module_name=serialpo
rt --module_path=G:\ARTnodejs\ardunode_modulesserialport\buildRelease --python=C:\Python27\python.exe --msvs_version
=2017 )
Traceback (most recent call last):
File "C:\Program Filesnodejsnode_modules\npmnode_modulesnode-gypgypgyp_main.py", line 16, in
sys.exit(gyp.script_main())
File "C:\Program Filesnodejsnode_modules\npmnode_modulesnode-gypgyp\pylibgyp__init__.py", line 545, in script_m
ain
return main(sys.argv[1:])
File "C:\Program Filesnodejsnode_modules\npmnode_modulesnode-gypgyp\pylibgyp__init__.py", line 538, in main
return gyp_main(args)
File "C:\Program Filesnodejsnode_modules\npmnode_modulesnode-gypgyp\pylibgyp__init__.py", line 514, in gyp_main
options.duplicate_basename_check)
File "C:\Program Filesnodejsnode_modules\npmnode_modulesnode-gypgyp\pylibgyp__init__.py", line 98, in Load
generator.CalculateVariables(default_variables, params)
File "C:\Program Filesnodejsnode_modules\npmnode_modulesnode-gypgyp\pylibgyp\generator\msvs.py", line 1900, in C
alculateVariables
generator_flags.get('msvs_version', 'auto'))
File "C:\Program Filesnodejsnode_modules\npmnode_modulesnode-gypgyp\pylibgyp\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 Filesnodejsnode_modules\npmnode_modulesnode-gyplib\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:\ARTnodejs\ardunode_modulesserialport
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:\ARTnodejs\ardu
node_modulesserialport\buildReleaseserialport.node --module_name=serialport --module_path=G:\ARTnodejs\ardunode_mo
dulesserialport\buildRelease --python=C:\Python27\python.exe --msvs_version=2017' (1)
node-pre-gyp ERR! stack at ChildProcess. (G:\ARTnodejs\ardunode_modulesserialportnode_modulesnode-pr
e-gyplib\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:\ARTnodejs\ardunode_modulesserialport
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:\ARTnodejs\ardunode_modulesserialport\build\
Releaseserialport.node --module_name=serialport --module_path=G:\ARTnodejs\ardunode_modulesserialport\buildRelease
--python=C:\Python27\python.exe --msvs_version=2017' (1)
npm WARN [email protected] 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! [email protected] install: node-pre-gyp install --fallback-to-build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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:\ARTnodejs\ardu\npm-debug.log
```

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

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

@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

This looks like you're rebuilding the binaries, exactly what needs to happen


Francis Gulotta
[email protected]

On Mon, Jul 24, 2017 at 10:33 AM, franz1900 notifications@github.com
wrote:

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 11/12

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.binelectron-rebuild
  7. del .node_modules\nslog\buildRelease\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.binelectron-rebuild

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/EmergingTechnologyAdvisors/node-serialport/issues/538#issuecomment-317496615,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABlbvRm1VB-I9HbS3ogczz775fux3Weks5sRNVRgaJpZM4E3qag
.

this error is ??

image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

callen5914 picture callen5914  Â·  7Comments

JBtje picture JBtje  Â·  8Comments

rwaldron picture rwaldron  Â·  7Comments

HemantJoshi picture HemantJoshi  Â·  4Comments

callen5914 picture callen5914  Â·  8Comments