Node-gyp fails on serialport

I have tried to use the serialport port module but it failed badly on the compilation to native. I then created an application without serialport and published it. After that I open the console on a device and simply did an <npm i -serialport>. Voilà it went through. Back at my application I re-added the serialport functionality, published it again and no errors were found an my application worked perfectly.
Can You help me understanding this?

(using the latest dev image)


I’m not sure what was the error and the compilation was failing. Could it be that you have added some requirements afterwards and then performed the nom install? And thus, now it works?


nope, no new requirements were added
mvh - T

@ekskog, Hmm, I’m not sure, but could possibly be a random node-gyp failure. I’ve hit node-gyp errors in the past on my local machine which were fixed with clearing npm cache and re-installing. So a wild guess is that it’s more likely an issue with npm/node-gyp than the builders them selves.

But again it’s a guess so please do let us know if you hit this again.

We use the node serialport module to get some old school Modbus sensors up and running and ran into the same problem.

The binaries for the module must be compiled on the device at startup. We do this with the Dockerfile command CMD:

CMD npm install serialport && <start your application>

This works for us. Bit tricky but the compiled binaries are not the same than on your development machine.

Hey @matt, @ekskog.

Compilation shouldn’t be a problem because the build servers architecture matches that of the target device. So if you are pushing to a raspberrypi you will get an arm build environment.

I tried it out and came across a couple errors, firstly because I tried to compile it on a slim image which doesn’t have build-tools installed and then because I tried it on node 8 and npm 5 isn’t very reliable yet. But I got it too build you can see the changes from our default node project here:

If you are hitting other issues, than I mentioned above do let us know.