Reputation: 3285
I am trying to get serialport (https://www.npmjs.com/package/serialport) to work on windows so that I can send commands to my serial port and hence open/close the lock.
The serialport was installed via bash.
npm install serialport --save-dev
Below is the error
C:\Users\[...]\electron-with-express\express-app\node_modules\bindings\bindings.js:83
Error: %1 is not a valid Win32 application.
Below is the page
var express = require('express');
var router = express.Router();
var SerialPort = require('serialport');
// check which port is available
//var sp = require('../');
/* GET home page */
router.get('/', function(request, response){
//sp.list(function(err, ports) {
// console.log(ports);
//});
SerialPort.list(function (err, ports) {
ports.forEach(function(port) {
console.log(port.comName);
console.log(port.pnpId);
console.log(port.manufacturer);
});
});
});
// Important
module.exports = router;
The NodeJs app is being run via Electron
Upvotes: 0
Views: 2723
Reputation: 14847
Native Node modules such as serialport
must be rebuilt to target the specific Electron version you're using, to do so follow the steps documented at http://electron.atom.io/docs/tutorial/using-native-node-modules/
There's also an open issue covering the topic, so if you get stuck at least read this comment.
Upvotes: 2