Closed djipco closed 4 years ago
I got a similar error when installing serialport. In my case I was using node.js version 13 running on OS X 10.15.3. When I downgraded to node.js 12 then serialport installed successfully.
In case it is useful here is one of the 4 compile errors I got:
../src/serialport.cpp:329:14: error: no matching member function for call to 'Set'
results->Set(Nan::New<v8::String>("cts").ToLocalChecked(), Nan::New<v8::Boolean>(data->cts));
I also found this PR in node that fixes their own example: https://github.com/nodejs/node-addon-examples/pull/121
I'm trying to figure out how to get it to work too. I originally had this working on Node 1.2.0, NW.js 0.12.3, and serialport 2.0.6. I'm in the process of trying to update the app and am now using Node 13.8.0, NW.js 0.44.2, and serialport 8.0.7. But when I follow the instructions, all it says is to create a .prebuildrc and that's it.
build_from_source=true
runtime=node-webkit
target=0.44.2
When I run the app I get this:
Uncaught Error: A dynamic link library (DLL) initialization routine failed.
\\?\C:\Users\Mariani\Development\derby-timer\src\node_modules\@serialport\bindings\build\Release\bindings.node
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1246:18)
at Module.load (internal/modules/cjs/loader.js:1024:32)
at Function.Module._load (internal/modules/cjs/loader.js:923:14)
at Module.require (internal/modules/cjs/loader.js:1064:19)
at require (internal/modules/cjs/helpers.js:72:18)
at bindings (C:\Users\Mariani\Development\derby-timer\src\node_modules\bindings\bindings.js:112:48)
at Object.<anonymous> (C:\Users\Mariani\Development\derby-timer\src\node_modules\@serialport\bindings\lib\win32.js:1:36)
at Module._compile (internal/modules/cjs/loader.js:1175:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1201:10)
at Module.load (internal/modules/cjs/loader.js:1024:32)
I'm running on a Windows 10 x64 machine. I tried
npm install --global node-gyp node-pre-gyp nw-gyp
npm install --global --production windows-build-tools
npm install serialport --build-from-source
to no avail. I'm in the same boat, what do I need to do to get it to rebuild properly for NW.js?
As far as osc
is concerned, the serialport
module was made optional which solved my problem.
Having said that, I found it excruciatingly difficult to use any module that rely on the serialport
module within NW.js. I have had nothing but problems when trying to recompile it. I have had issues with johnny-five
, dmx
, osc
, etc. At this point, I have pretty much given up...
If anybody has a solution, I'd love to hear it.
I remember having a lot of difficulty with it in the past and when I got it working I never touched it again. Which goes to show why my original program was running serialport v2 and it's now on v8. But it's been long enough, I figured it should be updated and unfortunately all my notes no longer apply. I feel like the documentation is missing a step between creating the .prebuildrc file and actually making it rebuild properly.
As I wrote above. I think it only works with Node version 12. Node version 13 seems to have changed some native API that node-serialport is using. I'm not familiar with NW.js, I was installing node-serialport directly. But based on the error reported in the first comment I'd guess it is the same problem.
I switched to NW.js version 0.42.0 which is the last version with Node version 12 (12.12.0) and it still displays the same error. I tried running
npm install serialport --build-from-source
again to no avail. Any other ideas/suggestions?
For those interested, I released chrome-apps-serialport
today. Its API matches that of node-serialport
which means it can be substituted wherever node-serialport
is used.
I submitted a PR to the firmata.js
team. If they merge it, we will be able to use Johnny-Five within NW.js without having to rely on node-serialport
at all.
By using firmata-io
and my new chrome-apps-serialport
module, I am now able to use Johnny-Five inside NW.js without having to recompile anything. Here's how:
const SerialPort = require("chrome-apps-serialport").SerialPort;
const Firmata = require("firmata-io")(SerialPort);
const five = require("johnny-five");
SerialPort.list().then(ports => {
const device = ports.find(port => {
return port.manufacturer && port.manufacturer.startsWith("Arduino")
});
const board = new five.Board({
io: new Firmata(device.path)
});
board.on("ready", () => {
console.log("Johnny-Five is ready!");
const led = new five.Led(13);
led.blink(500);
});
board.on("close", () => console.log("Closed!"));
});
Cheers!
I got a similar error when installing serialport. In my case I was using node.js version 13 running on OS X 10.15.3. When I downgraded to node.js 12 then serialport installed successfully.
In case it is useful here is one of the 4 compile errors I got:
../src/serialport.cpp:329:14: error: no matching member function for call to 'Set' results->Set(Nan::New<v8::String>("cts").ToLocalChecked(), Nan::New<v8::Boolean>(data->cts));
I also found this PR in node that fixes their own example: nodejs/node-addon-examples#121
Same problem with node v14.7 on Mac Hight Sierra 10.13.6. Dowgrade to node@12 resolved the installation of serialport Procedure to dowgrade here
I am trying to install the
osc
module which depends on theserialport
module. Since the project is run inside NW.js, I followed the appropriate instructions and added a.prebuilrc
file to the root of my project.While the installation process does go through all the way to the end, I am getting an error and the
osc
module does not work. In fact, when I try to useosc
, it reports the following error:Cannot find module '@serialport/bindings'
To find the source of the problem, I tried installing only the
serialport
module and I'm getting the same error during install.Ideas?
This is the full log of installation: